Title: Violin plot inconsistency between list and numpy · Issue #12178 · matplotlib/matplotlib · GitHub
Open Graph Title: Violin plot inconsistency between list and numpy · Issue #12178 · matplotlib/matplotlib
X Title: Violin plot inconsistency between list and numpy · Issue #12178 · matplotlib/matplotlib
Description: Bug report When feeding the same data to violin plot in list or in numpy array, the result is not the same. Code for reproduction import matplotlib.pyplot as plt import numpy as np data = [ [1, 2, 3] , [4, 5, 6] ] data_np = np.array(data...
Open Graph Description: Bug report When feeding the same data to violin plot in list or in numpy array, the result is not the same. Code for reproduction import matplotlib.pyplot as plt import numpy as np data = [ [1, 2, ...
X Description: Bug report When feeding the same data to violin plot in list or in numpy array, the result is not the same. Code for reproduction import matplotlib.pyplot as plt import numpy as np data = [ [1, 2, ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12178
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Violin plot inconsistency between list and numpy","articleBody":"### Bug report\r\n\r\nWhen feeding the same data to violin plot in list or in numpy array, the result is not the same. \r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\ndata = [ [1, 2, 3] , [4, 5, 6] ]\r\ndata_np = np.array(data)\r\n\r\nf, (ax1, ax2) = plt.subplots(2)\r\n\r\nax1.violinplot(data)\r\nax1.set_title('list')\r\n\r\nax2.set_title('numpy array')\r\nax2.violinplot(data_np) #Same data but in numpy\r\n\r\nplt.show()\r\n\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\r\n\r\n\r\n**Expected outcome**\r\nBoth should be the same isn't it ?\r\n\r\nActually the [doc](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.violinplot.html#matplotlib.pyplot.violinplot) specify - in terms I didn't understood at first - that it will\r\n\"Make a violin plot for each column of dataset or each vector in sequence dataset. \" \r\n\r\nIt is more clear when looking at the [hist doc](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.hist.html), where one can read at the end\r\n\r\n\"Note that the ndarray form is transposed relative to the list form.\"\r\n\r\n\r\nThe difference between the two outcomes, I think, is the way of thinking at data : vectors in matrix or lists in list (which correspond to columns in array of row in array). \r\nI discussed with some collegues who are working with Matlab, and they do think the vector as base unit of the 2D matrix. For me the base unit is a row of a 2D array. \r\n\r\nIn the function plot when plotting [ [1,2,3], [4,5,6] ], we have 3 curves, so I thing it is the matrix/vector way of thinking that is predominant in matplotlib. \r\nSo should we change the violinplot and histogram behavior for list to work the same as array ?\r\n\r\nAfter writing this I do belive that the best solution is to just mention that specificity more clearly in the doc of violinplot, not changing the code. I can do this, but I would like some feedback from differents points of view before.\r\n\r\nBest,\r\nRP","author":{"url":"https://github.com/RaphP","@type":"Person","name":"RaphP"},"datePublished":"2018-09-20T08:04:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/12178/matplotlib/issues/12178"}
| 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:ea8ccbeb-1bb2-8a24-0470-ed19852380b8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DCAE:228F1C:28D908A:37F00ED:6A53B9B8 |
| html-safe-nonce | d271f63d1e00942ab7cdaf26549966020c927fb3002dcd9fa214d5d5e5abb967 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0FFOjIyOEYxQzoyOEQ5MDhBOjM3RjAwRUQ6NkE1M0I5QjgiLCJ2aXNpdG9yX2lkIjoiNDAxMDg3MjgwMzMzOTUxNjM0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f4267b71e0ad6261927db4c5ea4aae5890a8dce597dc80098b4bb04ec6a37dfa |
| hovercard-subject-tag | issue:362065398 |
| 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/12178/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1498ff08a004773cf29b979b563fd6df78f1109e583d08b61cbab443cf9e33a/matplotlib/matplotlib/issues/12178 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1498ff08a004773cf29b979b563fd6df78f1109e583d08b61cbab443cf9e33a/matplotlib/matplotlib/issues/12178 |
| og:image:alt | Bug report When feeding the same data to violin plot in list or in numpy array, the result is not the same. Code for reproduction import matplotlib.pyplot as plt import numpy as np data = [ [1, 2, ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RaphP |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width