如何在Julia中统一子图Y轴范围及优化分组直方图
分组直方图绘图优化问题
我想要绘制一幅分组直方图,展示事件按小时(0-23时)的分布情况。由于没找到更优雅的实现方式,我用了较为低效的绘图方法,当前效果如下:

所有子图的Y轴均为log10缩放,我需要对绘图做以下调整:
- 让所有子图的Y轴保持相同范围(尝试过多种方法但未成功);
- 添加X轴和Y轴全局标签(此前添加时每个子图都被赋予了相同的轴标签);
- 添加分组图的全局标题(使用
title = "Test"时,所有子图都被添加了该标题)。
当前代码如下:
p0 = StatsPlots.histogram((d1_0_degree), bins=50, yscale=:log10, label = "0", color = ColorSchemes.Set3_12.colors[1]) p1 = StatsPlots.histogram((d1_1_degree), bins=50, yscale=:log10, label = "1", color = ColorSchemes.Set3_12.colors[2]); p2 = StatsPlots.histogram((d1_2_degree), bins=50, yscale=:log10, label = "2", color = ColorSchemes.Set3_12.colors[3]); p3 = StatsPlots.histogram((d1_3_degree), bins=50, yscale=:log10, label = "3", color = ColorSchemes.Set3_12.colors[4]); p4 = StatsPlots.histogram((d1_4_degree), bins=50, yscale=:log10, label = "4", color = ColorSchemes.Set3_12.colors[5]); p5 = StatsPlots.histogram((d1_5_degree), bins=50, yscale=:log10, label = "5", color = ColorSchemes.Set3_12.colors[6]); p6 = StatsPlots.histogram((d1_6_degree), bins=50, yscale=:log10, label = "6", color = ColorSchemes.Set3_12.colors[7]); p7 = StatsPlots.histogram((d1_7_degree), bins=50, yscale=:log10, label = "7", color = ColorSchemes.Set3_12.colors[8]); p8 = StatsPlots.histogram((d1_8_degree), bins=50, yscale=:log10, label = "8", color = ColorSchemes.Set3_12.colors[9]); p9 = StatsPlots.histogram((d1_9_degree), bins=50, yscale=:log10, label = "9", color = ColorSchemes.Set3_12.colors[10]); p10 = StatsPlots.histogram((d1_10_degree), bins=50, yscale=:log10, label = "10", color = ColorSchemes.Set3_12.colors[11]); p11 = StatsPlots.histogram((d1_11_degree), bins=50, yscale=:log10, label = "11", color = ColorSchemes.Set3_12.colors[12]); p12 = StatsPlots.histogram((d1_12_degree), bins=50, label = "12", yscale=:log10, color = ColorSchemes.Paired_12.colors[1]); p13 = StatsPlots.histogram((d1_13_degree), bins=50, label = "13", yscale=:log10, color = ColorSchemes.Paired_12.colors[2]); p14 = StatsPlots.histogram((d1_14_degree), bins=50, label = "14", yscale=:log10, color = ColorSchemes.Paired_12.colors[3]); p15 = StatsPlots.histogram((d1_15_degree), bins=50, label = "15", yscale=:log10, color = ColorSchemes.Paired_12.colors[4]); p16 = StatsPlots.histogram((d1_16_degree), bins=50, label = "16", yscale=:log10, color = ColorSchemes.Paired_12.colors[5]); p17 = StatsPlots.histogram((d1_17_degree), bins=50, label = "17", yscale=:log10, color = ColorSchemes.Paired_12.colors[6]); p18 = StatsPlots.histogram((d1_18_degree), bins=50, label = "18", yscale=:log10, color = ColorSchemes.Paired_12.colors[7]); p19 = StatsPlots.histogram((d1_19_degree), bins=50, label = "19", yscale=:log10, color = ColorSchemes.Paired_12.colors[8]); p20 = StatsPlots.histogram((d1_20_degree), bins=50, label = "20", yscale=:log10, color = ColorSchemes.Paired_12.colors[9]); p21 = StatsPlots.histogram((d1_21_degree), bins=50, label = "21", yscale=:log10, color = ColorSchemes.Paired_12.colors[10]); p22 = StatsPlots.histogram((d1_22_degree), bins=50, label = "22", yscale=:log10, color = ColorSchemes.Paired_12.colors[11]); p23 = StatsPlots.histogram((d1_23_degree), bins=50, label = "23", yscale=:log10, color = ColorSchemes.Paired_12.colors[12]); p_degreelog = Plots.plot(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, frame=:box, layout = (4,6), legend = true, size=(1400, 600), link=(:x) )
内容的提问来源于stack exchange,提问作者Chao
相关产品推荐
相关产品推荐

