proplot-dev / proplot

🎨 A succinct matplotlib wrapper for making beautiful, publication-quality graphics
https://proplot.readthedocs.io
MIT License
1.11k stars 102 forks source link

When subplotting, all lines are plotted only in the last image plot #391

Closed Robotatron closed 2 years ago

Robotatron commented 2 years ago

Very basic example code, I am plotting images for each axis. Additionally, for each axis, I am plotting some lines with coco.plot.showAnns(anns) which in turn calls several pplt.pyplot.plot() functions

For some reason, instead of having lines plotted in each image, all them are plotted only in the last one?

zxdawn commented 2 years ago

You can set all axis without gridline and then specify the last one you want:

import proplot as pplt

fig, axs = pplt.subplots(nrows=2, ncols=2)

axs.format(grid=False)
axs[-1].format(grid=True)
image
Robotatron commented 2 years ago

@zxdawn My question was not about gridlines. The problem I am having is that the plot from coco.plot.showAnns(anns) which is inside the loop it plotted only in the last image. It should have plotted on every image, instead all plots are only in the last image.

Robotatron commented 2 years ago

delete

Robotatron commented 2 years ago

Better example. I would expect the colored horizontal line to be plotted in every image. Instead all 4 are plotted only in the last image. image

Expectation: image

Robotatron commented 2 years ago

Figured it out after watching https://www.youtube.com/watch?v=6gdNUDs6QPc Basically, plot_line() has to be provided an instance of the Axes, then it works fine!

image