我正在用python制作一个图表,希望每个条形图数据点的中值所在的位置有一个圆圈,现在一组的中值在变量medf下
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
#import plotly.express as px
import pandas as pd
N = 4
ind = np.arange(N)
width = 0.25
cells = ['control', '15 cm', '30 cm', '30 cm homogenous']
medf = [ 17.89, 16.88,21.46,12.39] #fdle median
xvals = [15.168, 18.201, 19.730,13.07] #fdle
errorf = [2.98, 2.71,1.79, 0.789 ] #fdle error
bar1 = plt.bar(ind, xvals,width,yerr=errorf, ecolor='grey', color='lightcoral')
yvals = [20.94 , 21.90,22.87, 20.20] #calu
errorc = [0.617 , 3.432,1.578, 2.1] #need to redo errpr
bar2 = plt.bar(ind + width, yvals, width,yerr=errorc,ecolor='grey', color='lightseagreen')
zvals = [15.47,16.44, 37.7,13.63 ] #rle
errorr = [3.37 , 0.66,17.01, 6.04]
bar3 = plt.bar(ind + width * 2, zvals, width,yerr=errorr,ecolor='grey', color='thistle')
grey_patch = mpatches.Patch(color='grey', label='Standard Error')
#fig = px.box(df, x="cells", y="total_bill", color="smoker")
plt.xlabel("Pressure")
plt.ylabel('Distance (um)')
plt.title("Mean Total Distance Traveled")
plt.xticks(ind + width, ['Control', '15 cm', '30 cm', '30 cm homogenous'])
plt.legend((bar1, bar2, bar3,grey_patch), ('FDLE', 'CALU-3', 'RLE-6TN','Standard Error'))
plt.show()
我试过使用以下方法,但对我不起作用
ax.scatter(df['Val2'].tolist(), [0,1,2], color=[1,0.8,0], zorder=2, label='Val2')
1条答案
按热度按时间x8goxv8g1#
在你展示情节之前加上这句话对我很有效:
整个代码现在看起来如下所示:
希望这是有用的