我希望每个脊上的样本大小文本适用于下面的脊图(可能在右上角)。有没有人用joyplot尝试过。
import joypy
range_P = [0,500,1000,1500,2000,2500,3000]
labels = [('RZ for PRP. \n('+str(range_P[i])+'-'+str(range_P[i]+500)+' mm)') for i in range(7)]
fig, axes = joypy.joyplot([RZS_P['RZ'][(RZS_P['PRP'] > range_P[i]) & (RZS_P['PRP'] <= range_P[i]+500)] for i in range(7)],
ylim='own',
overlap = 0,
bins = 20,
figsize=(6,10),
alpha = 0.6,
labels = labels,
color ='#1f78b4'
)
plt.xlim(0,1000)
答案 0 :(得分:0)
当Joyplot绘制多个图形时,每个图形的轴都是独立的。因此,您可以设置一个位置并用于循环。
我无法复制您的代码,但是使用了joyplot author's code。文本t1,t2,t3,t4设置在每个图形的右侧。
1。从某处下载iris.csv。
2。设置样本= []。
3。根据需要,通过adjustig y_position = axes[i].get_ylim()[1] / 3.5
设置axes []。text(x,y,..)的x和y。
import joypy
import pandas as pd
from matplotlib import pyplot as plt
from matplotlib import cm
iris = pd.read_csv("iris.csv")
sample = ['t1', 't2', 't3', 't4']
%matplotlib inline
fig, axes = joypy.joyplot(iris, ylim='own')
for i in range(len(sample)):
y_position = axes[i].get_ylim()[1] / 3.5 # adjust with ylim for each plot
axes[i].text(9, y_position, sample[i])