New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: White voids near boundaries of polar plot relating to figure size and saving dpi #26286
Comments
Because of no answering in the issues, I post it in stack overflow, too, as a bounty question, which didn’t get any answer, too. I would be very grateful if the developers or the experts of this library who know any solution or … would guide me and answer in one of these two links. I am pinging based on contribution in similar posts, @ianthomas23 , @jklymak , @timhoffm , @dstansby |
The contouring algorithm doesn't know that it is acting on a polar plot, so when the contours are drawn in polar space the polygons are approximated. It's really hard to imagine doing much more for this, and your approaches of interpolating the data seem fine. |
Now that contouring is in a separate repo in contourpy, @ianthomas23 may be able to provide more projection-specific contouring? |
I have mentioned him in my last comment. I produce more points among the arrays and interpolate with method linear using RBF SciPy, It seems this way can be helpful in this regard, which result is smoother than linear method used in griddata SciPy (way 2). I will recheck my work, hope others could get a better solution. |
@alisheikholeslam Both If this bothered me I wouldn't draw the outer black circle, or I would draw it wider so no gaps are visibie. This isn't actually a contouring issue, it is an issue of whether a straight line in one coordinate system should be transformed to a straight or non-straight line in another coordinate system. It applies equally to any polygon (e.g. just a simple triangle) specified in, for example, polar coordinates, and rendered in cartesian (screen) coordinates. Currently all such lines are drawn straight, with the exception of polar bar charts (there might be more exceptions, I haven't checked). It would be possible, in general, to have a |
@ianthomas23 is there a configuration setting to increase the polygon point density? Going up a factor of 2-3 would likely be a practical workaround to fix the present case. |
No there isn't. |
Contouring is always an approximation. You will need to come up with a practical solution to this problem, rather than expect the algorithm to change. In the above, if I do |
@jklymak , I think this solution or something like thickening (or using thicker) the boundary are not good solutions and depending on the input data; I saw several examples that not-filled area is not small, unlike the example in this post, and using this solution for curing will miss a big area. @ianthomas23 thanks for the explanation and the possible solution. I am not very familiar with cartopy library, but will try to communicate with its experts if have problem in my future plots. As I said earlier, as a workaround, I tried to produce some data and interpolation, which solves the white voids issue near the boundaries and produce almost acceptable results in the SO link. By the way, I am seeking for any better solution than mine and not sure about closing this issue and leave it to you. Thank you all for participating in this issue. |
I think for the explanations given in comments above it's worth closing this as expected behaviour that we can't fix. Thanks for opening the issue though, and sorry there isn't a fix we can implement for it. |
Bug summary
I have a polar plot but it have some white areas near the circle boundary in just some sides of the plot. At first, I thought it needs some interpolations and tried interpolating based on some available methods e.g. 1 and 2. But not the good results. Interpolating using SciPy griddata with linear method solve the main issue but produce some shadows on the plot, and the cubic method result some inappropriate colors (which shown the results incorrect). Finally, I figure out that this issue is related to figure size that I specified and the dpi that I use. with low dpi it was cured a lot but low quality png. when I deactivate the related line for specifying figure size (
plt.rcParams["figure.figsize"] = (19.2, 9.6)
), it is shown correctly. How to pass the issue?I will be appreciated if any answer about these questions too:
Code for reproduction
Actual outcome
Expected outcome
Additional information
Stack Overflow reposted link due to being unanswered here
Operating system
Windows 10
Matplotlib Version
3.5.3, 3.7.1, 3.7.2
Matplotlib Backend
No response
Python version
3.8, 3.10
Jupyter version
No response
Installation
conda
The text was updated successfully, but these errors were encountered: