[yt-users] custom axes tickmarks projection plot

Nathan Goldbaum nathan12343 at gmail.com
Mon Aug 10 11:49:38 PDT 2015


On Mon, Aug 10, 2015 at 1:33 PM, Gabriel Goodwin <ggoodwin52 at gmail.com>
wrote:

> Hello All,
>
> Does know how to specify custom tickmark locations for the y axis of a
> projection plot in the 3.2 release? I was able to do it in 3.1 using the
> following code:
>
> p =
> yt.ProjectionPlot(ds,2,string,center=[cent,height,0],width=(wide,height),origin="native",data_source=cut,method='integrate',weight_field='temperature')
> ax = p.plots[string].axes
> ax.yaxis.set_ticks([0.00, 0.15, 0.30])
>
> This would place tickmarks and their labels on the y axis at 0, 0.15, and
> 0.3.
>
> When I try and do this using yt 3.2 I get the following error:
>
> AttributeError                            Traceback (most recent call last)<ipython-input-76-6e901a613181> in <module>()     16 ax = p.plots[string].axes---> 17 ax.yaxis.set_ticks([0.00, 0.15, 0.30])
> AttributeError: 'NoneType' object has no attribute 'yaxis'
>
>
This is due to a performance improvement that was merged in after 3.1 went
out.  See:
https://bitbucket.org/yt_analysis/yt/pull-requests/1481/plot-window-performance/diff

The quick fix is to call "p._setup_plots()" before manipulating the axes
object. The error you're seeing is because we don't actually call out to
matplotlib anymore until just before the plots need to be created to be
saved to disk or displayed to a user.

You're definitely not doing anything crazy and the way it works now is
definitely a bit nonintuitive if you're used to the plots being valid
immediately after calling ProjectionPlot.

One thing I could see doing is to make sure the plot is created if a user
*does* actually try to access the axes object. This could be done by making
the "axes" attribute a property that returns the axes if it's been created
already or creates the axes if it hasn't yet been created and then returns
them. That would take a little bit of coding work to get functional.

Please feel free to file an issue about this or take a stab at implementing
it yourself. I can't guarantee that I'll be able to work on this myself on
a short timescale, but filing the issue will prevent us from forgetting
about it.

-Nathan


>
> It appears that we can no longer manipulate the axes object like we were able to in 3.1.
>
> Thank you!
>
>
>
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20150810/fe336c44/attachment.htm>


More information about the yt-users mailing list