properties of patch of an axes instance.

Sorry if the subject line does not use correct terminology. But the
following explains the question I have:
Suppose I have the following code:

import matplotlib.pyplot as plt

fig1 = plt.figure()
ax1 = fig1.add_subplot(1,1,1)

ax1.scatter(xvalues, yvalues)
ax1.axvline(1.3, color='DarkGreen')
rect = ax1.patch
rect.set_facecolor('SteelBlue') #This works
rect.set_edgecolor('red') # Is it supposed to set the color of the
border. If so, this DOES NOT work.
rect.set_linestyle('dashed') # This DOES NOT work.
rect.set_linewidth(4) # This DOES NOT work.

For the things that do not work, I tried both

plt.show()

and,

plt.savefig('this_figure.pdf')

Why do the things that I have indicated do not work?

My second question is, if I want to have only the x-axis and y-axis
line (i.e., get rid of the right edge and top edge of the axes frame)
how do I do it?

I am using the Matplotlib version that comes with Enthought Python
Distribution 6.3.

Thanks for your help.

Curiouslearn, on 2011-02-08 15:32, wrote:

Sorry if the subject line does not use correct terminology. But the
following explains the question I have:
Suppose I have the following code:

import matplotlib.pyplot as plt

fig1 = plt.figure()
ax1 = fig1.add_subplot(1,1,1)

ax1.scatter(xvalues, yvalues)
ax1.axvline(1.3, color='DarkGreen')
rect = ax1.patch
rect.set_facecolor('SteelBlue') #This works
rect.set_edgecolor('red') # Is it supposed to set the color of the
border. If so, this DOES NOT work.
rect.set_linestyle('dashed') # This DOES NOT work.
rect.set_linewidth(4) # This DOES NOT work.

For the things that do not work, I tried both

plt.show()

and,

plt.savefig('this_figure.pdf')

Why do the things that I have indicated do not work?

My second question is, if I want to have only the x-axis and y-axis
line (i.e., get rid of the right edge and top edge of the axes frame)
how do I do it?

The names of the things you want to change are called spines.

You want:

  ax1.spines['right'].set_visible(False)
  ax1.spines['top'].set_visible(False)
  ax1.spines['left'].set_color('red')
  ax1.spines['bottom'].set_color('red')
  #and so on for .set_linestyle, .set_linewidth

To hide the tickmarks that are right next to the spines, you can
do:

  ax1.xaxis.tick_bottom()
  ax1.yaxis.tick_left()

and finally, to color the ticks in red as well, do:

  ax1.tick_params(color='red')

best,

···

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

Thanks very much Paul. This worked great.

I wonder then what edgecolor, linewidth etc. change in case of axes.patch.

Thanks again.

···

On Tue, Feb 8, 2011 at 6:22 PM, Paul Ivanov <pivanov314@...287...> wrote:

Curiouslearn, on 2011-02-08 15:32, wrote:

Sorry if the subject line does not use correct terminology. But the
following explains the question I have:
Suppose I have the following code:

import matplotlib.pyplot as plt

fig1 = plt.figure()
ax1 = fig1.add_subplot(1,1,1)

ax1.scatter(xvalues, yvalues)
ax1.axvline(1.3, color='DarkGreen')
rect = ax1.patch
rect.set_facecolor('SteelBlue') #This works
rect.set_edgecolor('red') # Is it supposed to set the color of the
border. If so, this DOES NOT work.
rect.set_linestyle('dashed') # This DOES NOT work.
rect.set_linewidth(4) # This DOES NOT work.

For the things that do not work, I tried both

plt.show()

and,

plt.savefig('this_figure.pdf')

Why do the things that I have indicated do not work?

My second question is, if I want to have only the x-axis and y-axis
line (i.e., get rid of the right edge and top edge of the axes frame)
how do I do it?

The names of the things you want to change are called spines.

You want:

ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_color('red')
ax1.spines['bottom'].set_color('red')
#and so on for .set_linestyle, .set_linewidth

To hide the tickmarks that are right next to the spines, you can
do:

ax1.xaxis.tick_bottom()
ax1.yaxis.tick_left()

and finally, to color the ticks in red as well, do:

ax1.tick_params(color='red')

best,
--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk1R0CoACgkQe+cmRQ8+KPcmJwCgk8DmrReu7A+v8qSqK0OmXxFe
HWQAnjRAogcretSNthEJN82koTuPmFhx
=zzWa
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Curiouslearn, on 2011-02-08 19:04, wrote:

I wonder then what edgecolor, linewidth etc. change in case of axes.patch.

They do what one would expect, but the spines were likely
preventing you from seeing this:

ax = plt.subplot(1,1,1)
[s.set_visible(False) for s in ax.spines.values()]
ax.patch.set_linewidth(2)
ax.patch.set_edgecolor('red')
plt.draw()

best,

···

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

Thanks again, Paul! Now I understand. I tried your example and I can
see the effect of those commands.

···

On Tue, Feb 8, 2011 at 7:29 PM, Paul Ivanov <pivanov314@...287...> wrote:

Curiouslearn, on 2011-02-08 19:04, wrote:

I wonder then what edgecolor, linewidth etc. change in case of axes.patch.

They do what one would expect, but the spines were likely
preventing you from seeing this:

ax = plt.subplot(1,1,1)
[s.set_visible(False) for s in ax.spines.values()]
ax.patch.set_linewidth(2)
ax.patch.set_edgecolor('red')
plt.draw()

best,
--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk1R39oACgkQe+cmRQ8+KPd9xgCfQcoPu5wU9O/k5IqlsTlUpTKD
P6sAnjPfi4Dv1xxEDDB8WxVtiy7s1Oj9
=/N2z
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users