下面的绘图是使用“ matplotlib ”完成的。我正在尝试删除x轴上的空白。即x轴上的2。
我的x轴是天,y轴是计数,在第2天没有计数,它显示空白,需要从绘图中删除它。代码如下所示
x=Covox_Call["Day"]
y_1=Covox_Call["Cumilative Contacted"]
y_2=Covox_Call["Not Contacted"]
plt.bar(x,+y_1,label="Contacted")
plt.bar(x,-y_2,label="Not Contacted")
plt.xticks(Covox_Call["Day"])
答案 0 :(得分:2)
您可以考虑使用基于matplotlib的熊猫绘图方法:
current.folder <- "G:\\Team Drives\\USDA_SCRI\\UCSC_field_trial_results\\Gasmet\\G2\\180828_180829_G2\\Samples\\"
setwd("G:\\Team Drives\\USDA_SCRI\\UCSC_field_trial_results\\Gasmet\\G2\\180828_180829_G2\\Samples\\")
new.folder <- "C:\\Users\\pres9340\\Desktop\\test"
list.of.files = list.files(current.folder, G2_1A27$Spectrum.file)
创建:
答案 1 :(得分:1)
最简单的解决方案是不使用"Day"
作为x值,而仅将其用作标签。这些值只是连续的值(np.arange(...)
):
Covox_Call = pd.DataFrame()
Covox_Call["Day"] = [1,3,4]
Covox_Call["Cumilative Contacted"] = [31,111,156]
Covox_Call["Not Contacted"] = [688,608,563]
x=np.arange(Covox_Call["Day"].shape[0])
y_1=Covox_Call["Cumilative Contacted"]
y_2=Covox_Call["Not Contacted"]
plt.bar(x,+y_1,label="Contacted")
plt.bar(x,-y_2,label="Not Contacted")
plt.xticks(x, Covox_Call["Day"])