Comments (3)
You mean you want access to the y values of the curve?
Exposing the data computed by kde would be a bit of a mess.
There is a workaround, as there always is in matplotlib.. -- you can extract the "line" elements for each axis and then extract the y values, then you can take the max.
Something like:
iris = pd.read_csv("iris.csv")
fig, axes = joypy.joyplot(iris)
median = [6,3,3.5,1]
for i in range(4): #the axis from 0 to 3 contain the actual subplots
ymin = 0
ymax = axes[i].lines[1].get_ydata().max() #the line we're interested in is actually the second one
axes[i].plot([median[i]] * 2, [ymin, ymax], color="red", zorder=200) #need to set a high zorder to draw them in front of all the rest
resulting in:
from joypy.
This is great, thank you! I had been exploring the axes elements and their sub-elements but somehow missed the get_ydata(). But thank you again!!
Edit: Ah but wait.. Can I also get the y value at any x value from get_ydata()?
Edit 2: YES! So I wanted to get the mean value for each distribution and plot it.
means = [iris.SepalLength.mean(), iris.SepalWidth.mean(), iris.PetalLength.mean(), iris.PetalWidth.mean()]
fig, axes = joypy.joyplot(iris)
for i in range(4): #the axis from 0 to 3 contain the actual subplots
ymin = 0
mean = means[i]
yval = axes[i].lines[1].get_ydata()[np.where(np.round(axes[i].lines[1].get_xdata(),2) == np.around(mean,2))[0][0]]
axes[i].plot([mean,mean], [ymin, yval], color="red", zorder=200) #need to set a high zorder to draw them in front of all the rest
Thanks again!
from joypy.
You're welcome!
from joypy.
Related Issues (20)
- ENH: Add logscale option HOT 2
- import fails with latest version of pandas HOT 2
- Not enough colors in matplotlib default color cycle to draw all subplots
- Aggregate data in a specific column HOT 3
- Unexpected behaviour of figsize and overlap HOT 6
- Incorrect plotting of standard gaussian? HOT 1
- Typo in "num_axes" variable? HOT 1
- Update Iris Example in Readme HOT 1
- "By" Column Is Not Properly Removed HOT 1
- Rotate ridges 90 degrees? HOT 1
- How to align all y_series?
- Joypy and gridspec HOT 2
- Is it possible to inverse the plot?
- Is it possible to change joyplot's zorder? HOT 1
- Github Tags/Releases? HOT 2
- Passing axis parameter into new joyplot function call?
- How you can set different colors in Hist mode for each group? HOT 1
- Color gradient along horizontal axis rather than the vertical axis HOT 5
- Specify the order of groups
- List of colors not allowed when `hist = True`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from joypy.