Open kgoebber opened 4 years ago
Re-opening so I remember to upstream this somewhere.
@kgoebber is the "other contour labelling issue that is being resolved within Cartopy itself" the issue where an export to a PostScript file loses the contour labels?
Example:
This is the result of PanelContainer.save('bug.ps')
where using PanelContainer.show()
looks fine (as does saving to a PNG).
Or should I submit a new issue for this?
@sgdecker No, we've not seen that before. However, I have trouble believing MetPy itself could be causing it and that it's not an issue in matplotlib (or Cartopy). Can you share the code you used to generate and the bug.ps
file you generated?
The Problem: There has been an issue with plotting contour labels for some time with the declarative syntax, but I wasn't able to diagnose it more fully until now. This is different than the other contour labelling issue that is being resolved within Cartopy itself. I have some fake data examples to illustrate.
The following example gives the expected behavior:
But now, if you set the extent at a later point in the code you get the following behavior...
Yowzah! Look at those missing contour pieces just for labelling the lines!
It turns out that the current behavior in the MetPy declarative syntax is to set the extent late and give output that looks like this:
The Answer:
So a PR is forthcoming on this issue with will just move the setting of the extent earlier in the draw process - no other changes needed to get a consistent behavior. There are currently three failing tests as a result of changing this order in how declarative draws the images. Two are based on contour labelling (will replace those images for sure), one is not. The one that is not is an
ImagePlot()
that has subtle changes after this change.All of this is kinda disturbing as I don't know why this ordering produces different results, but alas it does. It might lie somewhere upstream in Cartopy?