===== Original message from John Hunter | Sat, 02 Jul 2005:
>> props = dict(color='black', linestyle='--', linewidth=1)
>> axvline(x=0, **props) axhline(y=0, **props)
> this is nice, i like this. the only problem with this
> approach, compared to using actual gridlines, is that it
> sets axis ranges, so it might be a problem when data are
> not located around zero.
Yes, this is a potential problem with this approach, but you can
always set the xlim and ylim manually. One could add a kwarg to the
various plot commands like noupdate to suppress updating the datalim,
but I don't know if there are enough use cases to justify this
convenience over simply setting the view limits manually.
> i'm using this for plotting PCA Scores, calculated via the
> ChemoPy package. in many chemometrics applications the
> usual thing is to use the sample number, or variable names
> (for the loadings plot), as a plotting symbol. are there
> currently a routine for this in matplotlib?
> i think i can create such a plot using a for-loop and
> figtext, and still be able to color the dot and the text
> using a colormap?
Yes, you could do this, but it would take a bit of work to get
everything right. Basically, you would like to add string symbol
markers to scatter, and have them colored with colormaps and support
variable sizeing as well, right? The right way to do this, I think,
would be to implement a TextCollection, following the examples in
collections.py. Otherwise it would be extremely slow for large
numbers of markers. This would be a useful class anyhow to support
drawing of text with shared property (eg tick labels) since text
drawing is slow and is a bottleneck in some applications.
> what approach do you recommend for scaling the marker size
> relative to axis ranges and figure size?
I'm not sure what you are after here. marker sizes are in points, so
you can pick the physical sizes you want.
>> If for some reason you *really* want to use the actual
>> gridlines functionality w/o affecting the ticks, you could
>> selectively toggle the visible property of the gridlines you do
>> not want to show.
> how can i do this?
Here is the basic idea -- this is untested so it might have an error
for gline in ax.get_xgridlines():
xmin, xmax = gline.get_xdata() # both should be the same
gline.set_visible(xmin==0.0) # visible only at x==0
and then do the same for y. Of course you will need to make sure you
actually have a tick/grid at 0. Let me know how this works.