spines are tricky!

Starting with code written by Jae-Joon Lee, I constructed a template program
for creating plots with multiple y-axes. The program mostly works, but there
are two odd glitches:

(1) Not only is the y-axis for dependent variable #1 blue (as it should be),
but the entire frame around the plot is blue.

(2) The y-axis for dependent variable #2 has two sets of tick labels. The
set in black contains the correct values in the correct positions, but has
the wrong color. The other set of tick labels has the correct color (dark
red), but the values and locations are wrong. (In fact, these are same
values and positions as for dependent variable #1).

http://www.nabble.com/file/p26088693/multiple_yaxes_with_spines.png
http://www.nabble.com/file/p26088693/multiple_yaxes_with_spines.py
multiple_yaxes_with_spines.py

Any suggestions as to how I can fix these two problems will be greatly
appreciated.

P.S. I'm creating this program for use by students in the Engineering
Academy at Dos Pueblos High School, partly because they need something like
this for the projects that they are working on, and partly because I would
like to have them get some exposure to Python and Matplotlib.

P.P.S. This program has to be able to correctly generate a plot with 2, 3,
or 4 y-axes, although it would be good if it can also handle the
conventional case of a single y-axis. Students should be able to create
plots by simply inserting their data into the code and changeing the
variable label text strings.

···

--
View this message in context: http://www.nabble.com/spines-are-tricky!-tp26088693p26088693.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

(1) Not only is the y-axis for dependent variable #1 blue (as it should be),
but the entire frame around the plot is blue.

at line 158, you're changing the color of all spines. Change the color
of spine that you only want to change.

(2) The y-axis for dependent variable #2 has two sets of tick labels. The
set in black contains the correct values in the correct positions, but has
the wrong color. The other set of tick labels has the correct color (dark
red), but the values and locations are wrong. (In fact, these are same
values and positions as for dependent variable #1).

At line 113, you're creating 4 twinx axes, instead of 3, i.e, the
figure has total of 5 axes.

Also, I recommend you to use the pythonic convention that list index
starts from 0.

Regards,

-JJ

···

On Tue, Oct 27, 2009 at 11:12 PM, Dr. Phillip M. Feldman <pfeldman@...2440...> wrote:

I very much appreciate the help, but I still haven’t been able to
figure out how to make this work.

If I get one y-axis with the ‘host’, and each invocation of twinx adds
another y-axis, then it seems that I must invoke twinx three times to
get four y-axes. Does twinx add more than one y-axis per invocation?
(The documentation that I’ve been able to find is ambiguous about this).

Also, I’ve experimented with selectively setting colors of specific
spines, but have not been able to figure out which ones I should be
changing.

My current code is attached.

Phillip

P.S. As per your suggestion, I’ve rewritten the code to follow the
Python list index convention.

Jae-Joon Lee wrote:

multiple_yaxes_with_spines.py (6.25 KB)

···

<pfeldman@…2440…>

I introduced a bug when converting the code to make indices start at
zero. This is fixed in the attachment.

Phillip M. Feldman wrote:

multiple_yaxes_with_spines.py (6.25 KB)

···

<pfeldman@…2440…>

twinx add a single axes.
In your original code, you were calling twinx 4-times.

See if the attached code works.

While I acknowledge that using spines with multiple y-axis is a bit
tricky, I don't think the situation will change anytime soon.

Regards,

-JJ

spine_multiy_test.py (6.45 KB)

···

On Wed, Oct 28, 2009 at 7:20 PM, Phillip M. Feldman <pfeldman@...2440...> wrote:

If I get one y-axis with the 'host', and each invocation of twinx adds
another y-axis, then it seems that I must invoke twinx three times to get
four y-axes. Does twinx add more than one y-axis per invocation? (The
documentation that I've been able to find is ambiguous about this).

This is tremendous. thanks!!

Phillip

Jae-Joon Lee wrote:

···

On Wed, Oct 28, 2009 at 7:20 PM, Phillip M. Feldman > <pfeldman@...2440...> wrote:
  

If I get one y-axis with the 'host', and each invocation of twinx adds
another y-axis, then it seems that I must invoke twinx three times to get
four y-axes. Does twinx add more than one y-axis per invocation? (The
documentation that I've been able to find is ambiguous about this).
    
twinx add a single axes.
In your original code, you were calling twinx 4-times.

See if the attached code works.

While I acknowledge that using spines with multiple y-axis is a bit
tricky, I don't think the situation will change anytime soon.

Regards,

-JJ