Julia中移除各密度图独立标题,仅保留整体图表标题的方法
移除子密度图独立标题,保留全局图表标题
当前图表中每个子密度图自带独立标题(Work、Home等),只需给每个density调用添加title=""参数,即可移除子图的独立标题,同时保留全局的图表标题。
修改后的代码如下:
plot( size=(1200, 800), # 调整图表尺寸(宽, 高) dpi=300, # 调整分辨率(每英寸点数) density(distances_work, label="Work", title="", legend=:topright, alpha=0.7, linecolor=:blue), density(distances_home, label="Home", title="", alpha=0.7, linecolor=:green), density(distances_shopping, label="Shopping", title="", alpha=0.7, linecolor=:red), density(distances_other, label="Other", title="", alpha=0.7, linecolor=:orange), title="Distance Distribution by Activity", # 全局图表标题 xlabel="Distance (meter)", ylabel="Density", linewidth=2, xlims=(0, maximum([distances_work; distances_home; distances_shopping; distances_other])), legendtitlefontsize=8, # 调整图例标题字号 grid=true, gridcolor=:lightgray, legend=:topright, framestyle=:box, )
修改说明
- 给每个
density()函数添加title="",强制清空子图的独立标题 - 保留全局的
title参数,确保整个图表只有一个统一标题
内容的提问来源于stack exchange,提问作者Chao
相关产品推荐
相关产品推荐

