Title: Rotate Markers in functions like plot, scatter, etcetera · Issue #19195 · matplotlib/matplotlib · GitHub
Open Graph Title: Rotate Markers in functions like plot, scatter, etcetera · Issue #19195 · matplotlib/matplotlib
X Title: Rotate Markers in functions like plot, scatter, etcetera · Issue #19195 · matplotlib/matplotlib
Description: Problem Markers can't be rotated in a given angle, this would be useful even for a highschool level (I work making diagrams for a highschool level), and in general to make Matplotlib even better for making geometric diagrams. Here is an ...
Open Graph Description: Problem Markers can't be rotated in a given angle, this would be useful even for a highschool level (I work making diagrams for a highschool level), and in general to make Matplotlib even better fo...
X Description: Problem Markers can't be rotated in a given angle, this would be useful even for a highschool level (I work making diagrams for a highschool level), and in general to make Matplotlib even bette...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19195
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Rotate Markers in functions like plot, scatter, etcetera","articleBody":"\u003c!--\r\nWelcome! Thanks for thinking of a way to improve Matplotlib.\r\n\r\n\r\nBefore creating a new feature request please search the issues for relevant feature requests.\r\n--\u003e\r\n\r\n### Problem\r\n\r\nMarkers can't be rotated in a given angle, this would be useful even for a highschool level (I work making diagrams for a highschool level), and in general to make Matplotlib even better for making geometric diagrams.\r\n\r\nHere is an example:\r\n\r\n\r\n\r\nI did this diagram with Matplotlib, the code became cumbersome when trying to make the little angle markers, the ones that are two small lines perpendicular to the angle arcs. So I searched in the documentation and it seems there is no way to make marks like this builtin, there is no way to create a small perpendicular line to the arc in the middle of the arc, but then I thought about using plot markers for this.\r\n\r\nThe only problem of using markers, is that they can't be rotated, there is no way you can tell Matplotlib to make the marker perpendicular nor tangent to the line in which it's placed, or is there a way? I ask you kindly in case any of you know a way to plot markers perpendicular to the line in which they are placed.\r\n\r\nStrangely this feature was being worked on since 2013, but it seems nothing came of it, see #2478\r\n\r\nThe way I have found to rotate markers, is using a private attribute from the markers called '_transform', this attribute has methods to rotate the marker, but it's private, this means that the API has not provided a way to access and change this attribute. Here is a minimal example to rotate the markers.\r\n\r\n```(python)\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.markers import MarkerStyle\r\n\r\nlist1 = [0, 1] #| x coordinates\r\nlist2 = [0, 0] #| y coordinates\r\n\r\np1 = [.5, 0] #| p1 stands for point1, the marker will be placed in this point\r\nmarker1 = MarkerStyle(r'$|||$')\r\nmarker1._transform.rotate_deg(45)\r\n\r\nplt.plot(list1, list2, 'o-k', linewidth = 1)\r\nplt.plot(p1[0], p1[1], 'k', marker = marker1)\r\n\r\n#T# show the results\r\nplt.show()\r\n```\r\nThis outputs the following diagram\r\n\r\n\r\nAs can be seen, the marker is rotated 45 degrees, this marker of three small parallel lines is very common in geometric diagrams. The problem here is that I had to directly manipulate a private attribute, instead of doing that through a specific function for that purpose, such as a setter function.\r\n\r\nMatplotlib should be capable of producing geometric diagrams, rotating markers is a basic necessity, and as I said before, I wish there could be a way to place the markers perpendicular or parallel to the line in which they are placed, so that the user wouldn't have to calculate the angle of rotation, but this isn't too bad, at least rotating the marker is necessary.\r\n\r\n### Proposed Solution\r\n\r\n\u003c!-- Provide a clear and concise description of a way to accomplish what you want. For example:\r\n\r\n* Add an option so that when [...] [...] will happen\r\n --\u003e\r\nAdd a wrapper function that acts as a setter for the rotation of markers. The issue #2478 probably has a better way than what I could come up with.","author":{"url":"https://github.com/Polirecyliente","@type":"Person","name":"Polirecyliente"},"datePublished":"2020-12-29T19:46:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/19195/matplotlib/issues/19195"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d9b8b011-7eb6-ad34-b1c7-9254fcdf7a0a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D30:1A2FA1:A6CF9DF:AA4A59A:6A50B62B |
| html-safe-nonce | 0fd166b1eb4cd04ca51200b178dd77679462daa2febc127e1a0a336454cb1730 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDMwOjFBMkZBMTpBNkNGOURGOkFBNEE1OUE6NkE1MEI2MkIiLCJ2aXNpdG9yX2lkIjoiODM4NTQxNDkwODM0NzQ2MzIxMSIsInJlZ2lvbl9lZGdlIjoic2VhIiwicmVnaW9uX3JlbmRlciI6InNlYSJ9 |
| visitor-hmac | b63abe747d86b345999b352c131d750417c3815ff58efb573356953925173b72 |
| hovercard-subject-tag | issue:776057709 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/19195/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0b9a6e21877ee6b18080d2d6f9f90017cab0cc0ab92c07f2cabf916dab8a1996/matplotlib/matplotlib/issues/19195 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0b9a6e21877ee6b18080d2d6f9f90017cab0cc0ab92c07f2cabf916dab8a1996/matplotlib/matplotlib/issues/19195 |
| og:image:alt | Problem Markers can't be rotated in a given angle, this would be useful even for a highschool level (I work making diagrams for a highschool level), and in general to make Matplotlib even better fo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Polirecyliente |
| hostname | github.com |
| expected-hostname | github.com |
| None | 63772747707af4093f0d5fc7aa1bb3bb55f412a9865207c4f421aa34c64cc404 |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ded53fe94e3ff1bb4dbf8cc77e285396c92580fb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width