-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Cleaning up kwargs in ContourSet #2369
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
Comments
@bassdx: The python contour code has been due a refactor for some time; in fact I seem to have half-heartedly promised to do that about a year ago! (see #367). The idea is to separate out the calculation/storage of the polygons from all the graphical stuff like colours, etc. This will allow users to perform contour calculations without any GUI overhead, plus the graphical-aware ContourSet class can inherit from Artist for improved consistency with other plotting operations. So in the long run we will get clipping from the Artist inheritance. However, I won't be able to do this for a few months. In the meantime, if you want to write a temporary solution then go for the one that is consistent with the other plotting functions as this is how it will end up. |
@ianthomas23 Did this get dealt with in your most recent triangulation work? |
@tacaswell: No, the two are unrelated. |
Doesn't seem like there has been any movement on this since the last update. Seems like two options are listed in the OP:
Recommend looking at the first while the broader contour discussion can continue. Recommend labeling as Difficulty: Medium. |
This is a continuation of a mailing list thread where we talked about how to clip a plot inside a polygon. It is a very useful application for people who are visualizing data on maps since often times we want to plot everything inside one region (country, state or province).
http://matplotlib.1069221.n5.nabble.com/Clipping-a-plot-inside-a-polygon-td41950.html
Currently for many types of plots this is not that hard to do using the clip_path keyword for most of the plotting functions, since the kwargs are usually used to modify properties of the artists to be generated by the plotting function. For example, suppose that I had a polygon defining the border of a country, poly, and some data to overlay on top.
Does what I want because the kwargs of pcolor let me modify the underlying PolyCollection instance. However, there are a few plotting functions where I cannot do this, most notably in contour / contourf:
Will work but the clip_path kwarg gets completely ignored. To get the result I want, I need to store the output of contourf and use the set_clip_path method on each collection instance:
So I looked at the code in contour.py and realized that no kwargs get passed when instantiating the collections. @pelson mentioned that this might call for an overhaul of how the kwargs get passed into a ContourSet. His suggestion was either adding a set_clip_path method directly to ContourSet, or a more thorough change of how the kwargs are getting passed so they are more consistent with the other plotting functions. Ideally, I would prefer the latter case since then for my usage case I could always get what I want just by passing in the kwarg directly. Additionally it would make the functionality of contour(f) more similar to the other plotting functions, ie some of the kwargs can be passed to the collections. Any thoughts on this?
The text was updated successfully, but these errors were encountered: