[yt-users] Overplotting lines and points onto slices and projections

Nathan Goldbaum nathan12343 at gmail.com
Mon Jun 19 18:47:36 PDT 2017


On Mon, Jun 19, 2017 at 7:42 PM, Nathan Goldbaum <nathan12343 at gmail.com>
wrote:

> Try doing your additional plotting after calling plot.show() once. If you
> don't want to display the plot, try calling the private _setup_plots()
> method:
>
> plt._setup_plots()
>
> What's happening is that yt doesn't know you've used the matplotlib axes
> yt is using internally for its plots, so it just overwrites your additional
> customizations when you call plt.show(). So long as your customizations are
> the last thing that happens after you've fully set up your plot with yt
> (including any yt plot annotations) then your customizations a should show
> up.
>
> If that doesn't help, if you can make a runnable example that demonstrates
> the issue you're running into one of us should be able to relatively
> straightforwardly demonstrate a workaround by modifying your example.
>
> This issue comes up a lot, it occurs to me that it would nice if we could
> come up with a public API where users can get access to the matplotlib
> primitives but yt still has control over when the user-provided custom
> plotting gets applied.
>

Following up on this, I've filed an issue proposing such an API

https://github.com/yt-project/yt/issues/1460


>
>
> On Mon, Jun 19, 2017 at 6:48 PM Setton, David Jonathan - (davidsetton) <
> davidsetton at email.arizona.edu> wrote:
>
>> Hi all,
>>
>>
>> I'm a relatively new user to yt, and I've been trying to figure out the
>> best way to overplot some curves onto images generated by
>> OffAxisProjectionPlot and OffAxisSlicePlot routines. My searching through
>> the cookbooks has pointed me towards this page, which seems to indicate
>> that accessing the matplotlib axes and figures are the right way to go
>> about this. Following the example, I've created a density slice plot of my
>> dataset and loaded in my plot in the following way:
>>
>>
>> dens_plot = slice.plots['density']
>>
>> figure = dens_plot.figure
>> axes = dens_plot.axes
>> colorbar_axes = dens_plot.cax
>>
>>
>> From here, my next step would be to plot the line I wish to plot using
>> axes.plot(). However, running slice.show() after doing this just shows the
>> original plot and does not contain the plot I've attempted to overplot. I'm
>> sure my misunderstanding comes from not being familiar with how matplotlib
>> works under the hood, but does anybody have any suggestions for the best
>> way to go about doing this? I would also like to plot individual points on
>> a projection plot in the xy-plane at some point, which I would assume has a
>> very similar method.
>>
>>
>> Best,
>>
>>
>> David
>> _______________________________________________
>> 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/20170619/d69b21e3/attachment-0001.htm>


More information about the yt-users mailing list