Jae-Joon Lee wrote:
> Use pylab's yticks command.
> 
> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.yticks
> 
> Or Axes.set_yticklabels together with Axes.set_yticks.
> 
> http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_yticklabels
> 
> -JJ

Or a make a very simple custom Formatter:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import ScalarFormatter

class PositiveFormatter(ScalarFormatter):
     def pprint_val(self, x):
         return ScalarFormatter.pprint_val(self, np.abs(x))

x = np.arange(0,20,0.1)
y = 100 * np.sin(x)
plt.plot(x, y)
ax = plt.gca()
ax.yaxis.set_major_formatter(PositiveFormatter())
plt.show()


This is a much safer way to handle it than trying to modify tick labels 
directly.

Eric
> 
> 
> On Fri, Jul 31, 2009 at 4:07 PM, Lukas Hetzenecker<l...@gmx.at> wrote:
>> Hello,
>>
>> I have y values in the range of -100 to 100.
>> I want that the negative values are shown as positive (the minus gets removed
>> from the output).
>>
>> I tried a for loop over all self.ax.get_yticklabels() and call
>> label.set_text("...") on each item but it didn't work - nothing got changed.
>>
>> If I print the label in the loop they seem to be empty:
>> Text(0,0,'')
>> Text(0,0,'')
>> Text(0,0,'')
>> ......
>>
>> Is there anything I do wrong?
>>
>> Thanks,
>> Lukas
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
>> trial. Simplify your report design, integration and deployment - and focus on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to