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
backend_pgf. Enable custom dashstyles in the pgf backend #1251
Conversation
This does not work in all cases. I will update the pull request to fix it |
This should be a more general solution that always write the full dash_list and and the dash_offset. I believe the offset is normally zero, but just in case I have added it. |
@pwuertz what do you think about this change? |
@@ -497,18 +497,16 @@ def _print_pgf_path_styles(self, gc, rgbFace): | |||
writeln(self.fh, r"\pgfsetstrokeopacity{%f}" % gc.get_alpha()) | |||
|
|||
# line style | |||
dash_offset,dash_list = gc.get_dashes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For PEP8 compliance there should be a space after the comma.
Thanks for taking care of this! The way I implemented dashed lines was more or less a reverse engineered solution because I haven't found a documentation of how this function should behave.. and I didn't know about gc.get_dashes() ^^. But one thing keeps me wondering.. when I increase the linewidth the distances between the dashes don't increase.. so if I use a "dottet" linestyle with a thick line it's actually vertically striped and not dotted :/. This is wrong from my point of view, but it seems to be the default behaviour in matplotlib. Your solution looks good! |
Could you maybe squash these to a single commit? |
I Agree that the scaling with line width is more natural and I only implemented it like this to match the other backends. |
… using get_dashes. Also dash lenght does no longer scale with line width consistent with other backends.
backend_pgf: custom dashstyles and compliance with other backends
I agree we should fix the scaling to line width issue, and fix it for all backends, but that should wait for the next release. I consider this a bugfix for the PGFD backend. Any reason not to put it in 1.2.x? |
No objections. It's the right thing to do because it matches the behaviour of the other backends. The best solution to solve the dash-style scaling is probably to account for the linewidth in gc.get_dashes(). This should then work for all the backends if they don't rely on hard-coded values as I did. |
The following code produces lines with identical standard dashes using the pgf backend.
This happens because the pgf backend only takes the linestyle argument into account but ignores the dashes. In addition the dash length is scaled with the linewidth in the pgf backend. This is inconsistent with other backends (I tested pdf and agg) where it is independent of the linewidth. This pull request fixes both these issues.