Skip to content

MarkerStyle transformation not carried over to legend #20613

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

Closed
mdaeron opened this issue Jul 9, 2021 · 8 comments
Closed

MarkerStyle transformation not carried over to legend #20613

mdaeron opened this issue Jul 9, 2021 · 8 comments

Comments

@mdaeron
Copy link

mdaeron commented Jul 9, 2021

Bug report

When I transform a MarkerStyle, it displays fine in the plot but not in the legend.

Code for reproduction

import matplotlib.pyplot as ppl
from matplotlib.markers import MarkerStyle

hdiamond = MarkerStyle("d")
hdiamond._transform.rotate_deg(90)

ppl.plot(0, 0, marker = hdiamond, label = 'foo', ls = 'None')
ppl.legend()

ppl.show()

Actual outcome

Screen Shot 2021-07-09 at 13 33 33

Matplotlib version

  • Operating system: macOS 10.15.7 (19H15)
  • Matplotlib version: 3.3.4
  • Matplotlib backend: MacOSX
  • Python version: 3.7.10
@jklymak
Copy link
Member

jklymak commented Jul 9, 2021

_transform is private. Is this how we want end users making rotated markers?

@jklymak
Copy link
Member

jklymak commented Jul 9, 2021

My understanding is that to rotate markers you should create a new Marker and specify it's path. That should work with legend.

@anntzer
Copy link
Contributor

anntzer commented Jul 9, 2021

Ah, indeed, I missed the fact that this was accessing a private attribute...

@mdaeron
Copy link
Author

mdaeron commented Jul 9, 2021

So just to be sure, rotating built-in markers is not supported?

@jklymak, the only way I know to create a new marker is:

import matplotlib.pyplot as ppl

m1 = [(0,-1), (-2,0), (0,1), (2,0), (0,-1)]
m2 = 'd'

kw = dict(mfc = 'w', mew = 20, ms = 100)

ppl.plot(-1, 0, marker = m1, **kw)
ppl.plot(1, 0, marker = m2, **kw)

ppl.axis([-2, 2, -1, 1])
ppl.show()

Which yields:

image

The two methods look nothing alike because AFAIK there is no user-facing method to specify the joinstyle for path-defined markers. Am I missing another way to produce "pointy" horizontal diamonds?

@jklymak
Copy link
Member

jklymak commented Jul 9, 2021

First, as far as I can tell the code above works fine on 3.4.2 - the marker is rotated 90 degrees in the legend

We could close this, or turn into an issue about better access to marker methods. In particular, I don't see why we wouldn't expose joinstyle for the user to modify when creating a marker. I think it should also be possible to have a transform argument, but transforms are always a bit messy.

@jklymak
Copy link
Member

jklymak commented Jul 9, 2021

See #19195 for discussion of this. I'll add the discussion of join style and close here, but PRs welcome for adding more functionality to markers!

@jklymak jklymak closed this as completed Jul 9, 2021
@mdaeron
Copy link
Author

mdaeron commented Jul 9, 2021

First, as far as I can tell the code above works fine on 3.4.2 - the marker is rotated 90 degrees in the legend

Oh, great, that's good news. Thanks.

We could close this, or turn into an issue about better access to marker methods. In particular, I don't see why we wouldn't expose joinstyle for the user to modify when creating a marker.

That would be really neat, especially since something like (5, 1, 0) produces a star with yet another joinstyle (bevel).

@jklymak
Copy link
Member

jklymak commented Jul 9, 2021

Adding rotation has the approval of the core devs, someone just has to do it! I don't see why anyone would object to adding jointstyle at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants