From: Daniele P. <dpa...@ya...> - 2010-07-17 18:37:49
Attachments:
plot.png
|
Hi everybody, I have a problem with a plot. I attach a figure to be easily understandable. As you can see from the figure, I have in the same area a line and a bar plot. The problem is that y=0 for right y axis is different with respect to left y axis one. I want the two y=0 to be the same. How can i do that? Excuse me for my bad english, I'm italian :) Thanks in advance. |
From: Thøger E. J. T. <th...@fy...> - 2010-07-20 15:13:14
|
One way is to specify the axes manually, e.g. setting: (with matyplotlib.pyplot importad as plt:) plt.axis([200, 500, -600, 600]) ...or whatever seems fitting for you, and do that on both of the y axes. That should align them nicely. On Sat, 2010-07-17 at 20:37 +0200, Daniele Padula wrote: > Hi everybody, > I have a problem with a plot. I attach a figure to be easily understandable. > > As you can see from the figure, I have in the same area a line and a bar > plot. The problem is that y=0 for right y axis is different with respect > to left y axis one. I want the two y=0 to be the same. > > How can i do that? > > Excuse me for my bad english, I'm italian :) > > Thanks in advance. > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Benjamin R. <ben...@ou...> - 2010-07-20 20:29:14
|
Somehow, this doesn't seem very satisfying. It is almost accidental. There has to be a better way to do this. Ben Root 2010/7/20 Thøger Emil Juul Thorsen <th...@fy...> > One way is to specify the axes manually, e.g. setting: > > (with matyplotlib.pyplot importad as plt:) > > plt.axis([200, 500, -600, 600]) > > ...or whatever seems fitting for you, and do that on both of the y axes. > That should align them nicely. > > On Sat, 2010-07-17 at 20:37 +0200, Daniele Padula wrote: > > Hi everybody, > > I have a problem with a plot. I attach a figure to be easily > understandable. > > > > As you can see from the figure, I have in the same area a line and a bar > > plot. The problem is that y=0 for right y axis is different with respect > > to left y axis one. I want the two y=0 to be the same. > > > > How can i do that? > > > > Excuse me for my bad english, I'm italian :) > > > > Thanks in advance. > > > ------------------------------------------------------------------------------ > > This SF.net email is sponsored by Sprint > > What will you do first with EVO, the first 4G phone? > > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > > _______________________________________________ Matplotlib-users mailing > list Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Thøger E. J. T. <th...@fy...> - 2010-07-21 13:43:21
|
That really depends on what you want to do. For one single graph with these specific values, it is quick and easy and hence very satisfying *if that is what you need*. No need to go across the river for water. But, Daniele came up with a different and more sturdy solution (that I have used in scripts of my own too), which is to specify the axes as max-of-the-data-plus-a-bit reflected about a centered zero axis. This is not data specific, more reusable, but also takes longer to write. On Tue, 2010-07-20 at 15:28 -0500, Benjamin Root wrote: > Somehow, this doesn't seem very satisfying. It is almost accidental. > There has to be a better way to do this. > > Ben Root > > 2010/7/20 Thøger Emil Juul Thorsen <th...@fy...> > One way is to specify the axes manually, e.g. setting: > > (with matyplotlib.pyplot importad as plt:) > > plt.axis([200, 500, -600, 600]) > > ...or whatever seems fitting for you, and do that on both of > the y axes. > That should align them nicely. > > > On Sat, 2010-07-17 at 20:37 +0200, Daniele Padula wrote: > > Hi everybody, > > I have a problem with a plot. I attach a figure to be easily > understandable. > > > > As you can see from the figure, I have in the same area a > line and a bar > > plot. The problem is that y=0 for right y axis is different > with respect > > to left y axis one. I want the two y=0 to be the same. > > > > How can i do that? > > > > Excuse me for my bad english, I'm italian :) > > > > Thanks in advance. > > > > ------------------------------------------------------------------------------ > > This SF.net email is sponsored by Sprint > > What will you do first with EVO, the first 4G phone? > > Visit sprint.com/first -- > http://p.sf.net/sfu/sprint-com-first > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Daniele P. <dpa...@ya...> - 2010-07-23 12:00:59
|
I solved the problem and I'm going to explain the solution I used, it can be useful for someone. y data for each series are contained into 2 different arrays, say y1 and y2. The code is the sequent: if max(y1) > max(y2): y_max = max(y1) else: y_max = max(y2) if min(y1) < min(y2): y_min= min(y1) else: y_min = min(y2) y_upper_limit = y_max+ y_max/10 # to leave some blank space on the top y_lower_limit = y_min + y_min/10 # to leave some blank space on the bottom Then, in your plot, you set ylim(y_lower_limit, y_upper_limit) and that's it. This solution is good because it doesn't depend on the order of magnitude of the processed data, while specifying axes manually can give some problems for very different data sets. I hope this message is correctly sent to the mailing list, the procedure for answering a message is not so immediate in my opinion. Then, I subscribed the mailing list, so from the following messages (I have some other problems) I will use a different e-mail address. Bye :) Il 20/07/2010 22:28, Benjamin Root ha scritto: > Somehow, this doesn't seem very satisfying. It is almost accidental. > There has to be a better way to do this. > > Ben Root > > 2010/7/20 Thøger Emil Juul Thorsen <th...@fy... > <mailto:th...@fy...>> > > One way is to specify the axes manually, e.g. setting: > > (with matyplotlib.pyplot importad as plt:) > > plt.axis([200, 500, -600, 600]) > > ...or whatever seems fitting for you, and do that on both of the y > axes. > That should align them nicely. > > On Sat, 2010-07-17 at 20:37 +0200, Daniele Padula wrote: > > Hi everybody, > > I have a problem with a plot. I attach a figure to be easily > understandable. > > > > As you can see from the figure, I have in the same area a line > and a bar > > plot. The problem is that y=0 for right y axis is different with > respect > > to left y axis one. I want the two y=0 to be the same. > > > > How can i do that? > > > > Excuse me for my bad english, I'm italian :) > > > > Thanks in advance. > > > ------------------------------------------------------------------------------ > > This SF.net email is sponsored by Sprint > > What will you do first with EVO, the first 4G phone? > > Visit sprint.com/first <http://sprint.com/first> -- > http://p.sf.net/sfu/sprint-com-first > > _______________________________________________ Matplotlib-users > mailing list Mat...@li... > <mailto:Mat...@li...> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first <http://sprint.com/first> -- > http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > <mailto:Mat...@li...> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |