Re: [Matplotlib-users] bug in set_yscale of bar graphs?

2009-11-12 Thread per freem
thanks to all for the replies. i am still having an issue with the log
scale of these plots. i am trying to hide the top and right axes of
the plot, since these should not be there when plotting a histogram or
a line plot. i use the following code:

import matplotlib
matplotlib.use('PDF')
import matplotlib.pyplot as plt
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
plt.rcParams['ps.useafm'] = True
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['font.size'] = 10

from mpl_toolkits.axes_grid.axislines import SubplotZero

fig = plt.figure(figsize=(5, 5), dpi=300)
ax = SubplotZero(fig, 1, 1, 1)
ax = fig.add_subplot(ax)
x = range(1, 11)
y = [5000, 900, 600, 500, 200, 110, 50, 20, 10, 5]
plt.plot(x, y, linewidth=1.5, c='k')
ax = plt.gca()
ax.set_yscale('log')
ax.axis[xzero].set_visible(True)
# make other axis (bottom, top, right) invisible.
invisible = [bottom, top, right]
for n in invisible:
ax.axis[n].set_visible(False)
plt.savefig('test_logscale.pdf')

if i do this, the bottom x-axis labels disappear.

 this only happens with SubplotZero -- which is needed to make the
irrelevant axes invisible, I think -- then the labels of the x-axis
disappear.

any idea how this can be fixed? i want those axes removed but i still
want the labels/ticks of the bottom x-axis to show.

thanks.

On 11/11/09, Gökhan Sever gokhanse...@gmail.com wrote:
 On Wed, Nov 11, 2009 at 4:25 PM, per freem perfr...@gmail.com wrote:
 hi all,

 I am trying to make a simple bar graph that has its yaxis scale set to
 log.  I use the following code:

 import matplotlib
 matplotlib.use('PDF')
 import matplotlib.pyplot as plt
 from matplotlib import rc
 rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
 plt.rcParams['ps.useafm'] = True
 rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
 plt.rcParams['pdf.fonttype'] = 42
 plt.rcParams['font.size'] = 10

 x = range(1, 11)
 y = [5000, 900, 600, 500, 200, 110, 50, 20, 10, 5]
 plt.figure(figsize=(5, 5), dpi=300)

 plt.bar(x, y)

 It should work scaling from within the bar()
 plt.bar(x, y, log=True)

 # plt.gca().set_yscale('log')

 plt.savefig('test_logscale.pdf')

 the problem is that the bar graphs do not appear -- instead, i simply
 get horizontal lines around where the top of the bar graph should
 appear. Any idea how to fix this?

 also, sometimes the x axis disappears when i try this. thanks.

 --
 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




 --
 Gökhan


--
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


Re: [Matplotlib-users] bug in set_yscale of bar graphs?

2009-11-12 Thread Jae-Joon Lee
On Thu, Nov 12, 2009 at 12:07 PM, per freem perfr...@gmail.com wrote:
 ax.axis[xzero].set_visible(True)
 # make other axis (bottom, top, right) invisible.

The ax.axis[xzero] is drawn along the y=0 line. Therefore, if you
use logscale, this axis become invisible.

 invisible = [bottom, top, right]
 for n in invisible:
    ax.axis[n].set_visible(False)


Is there any reason that you have to use SubplotZero? If you intend to
use it, you need to place the xzero axes not at y=0, but at some
meaningful location.
However, I think you're good without SubplotZero. Just use Subplot,
but do not make bottom axis invisible (see the example below).
On the other hand, I recommend you to consider using spines instead of
axes_grid toolkits.

 
http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html

Regards,

-JJ


from mpl_toolkits.axes_grid.axislines import Subplot

fig = plt.figure(figsize=(5, 5), dpi=100)
ax = Subplot(fig, 1, 1, 1)
ax = fig.add_subplot(ax)
x = range(1, 11)
y = [5000, 900, 600, 500, 200, 110, 50, 20, 10, 5]
plt.plot(x, y, linewidth=1.5, c='k')
ax = plt.gca()
ax.set_yscale('log')
invisible = [top, right]
for n in invisible:
   ax.axis[n].set_visible(False)

--
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


Re: [Matplotlib-users] bug in set_yscale of bar graphs?

2009-11-11 Thread Jae-Joon Lee
The bar command makes rectangles whose bottom position is 0.
The reason that bars disappear when you set log scale is that bottom
position of the bar become -infinity.
You may
   * set log scale before calling the bar
or
   * create bar plot but with reasonable (positive) bottom value. Take
a look at the docs.

Regards,

-JJ



On Wed, Nov 11, 2009 at 5:25 PM, per freem perfr...@gmail.com wrote:
 hi all,

 I am trying to make a simple bar graph that has its yaxis scale set to
 log.  I use the following code:

 import matplotlib
 matplotlib.use('PDF')
 import matplotlib.pyplot as plt
 from matplotlib import rc
 rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
 plt.rcParams['ps.useafm'] = True
 rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
 plt.rcParams['pdf.fonttype'] = 42
 plt.rcParams['font.size'] = 10

 x = range(1, 11)
 y = [5000, 900, 600, 500, 200, 110, 50, 20, 10, 5]
 plt.figure(figsize=(5, 5), dpi=300)
 plt.bar(x, y)
 plt.gca().set_yscale('log')
 plt.savefig('test_logscale.pdf')

 the problem is that the bar graphs do not appear -- instead, i simply
 get horizontal lines around where the top of the bar graph should
 appear. Any idea how to fix this?

 also, sometimes the x axis disappears when i try this. thanks.

 --
 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


Re: [Matplotlib-users] bug in set_yscale of bar graphs?

2009-11-11 Thread Gökhan Sever
On Wed, Nov 11, 2009 at 4:25 PM, per freem perfr...@gmail.com wrote:
 hi all,

 I am trying to make a simple bar graph that has its yaxis scale set to
 log.  I use the following code:

 import matplotlib
 matplotlib.use('PDF')
 import matplotlib.pyplot as plt
 from matplotlib import rc
 rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
 plt.rcParams['ps.useafm'] = True
 rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
 plt.rcParams['pdf.fonttype'] = 42
 plt.rcParams['font.size'] = 10

 x = range(1, 11)
 y = [5000, 900, 600, 500, 200, 110, 50, 20, 10, 5]
 plt.figure(figsize=(5, 5), dpi=300)

 plt.bar(x, y)

It should work scaling from within the bar()
plt.bar(x, y, log=True)

# plt.gca().set_yscale('log')

 plt.savefig('test_logscale.pdf')

 the problem is that the bar graphs do not appear -- instead, i simply
 get horizontal lines around where the top of the bar graph should
 appear. Any idea how to fix this?

 also, sometimes the x axis disappears when i try this. thanks.

 --
 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




-- 
Gökhan

--
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