如何在Julia的Algebra of Graphics中将linear()图层改为虚线或点线?
如何在Algebra of Graphics中修改linear()图层的线条样式
要把linear()图层的实线改成虚线或点线,你可以通过style()函数设置线条的linestyle属性,下面是两种实用实现方式:
方式一:给linear图层直接附加样式
修改graphLayers的定义,用*连接linear()和style(),指定目标线条样式:
using DataFrames using AlgebraOfGraphics using CairoMakie linearDataFrame = DataFrame(a = 1:10, b= 0.1*(1:10)); mainGraphData = data(linearDataFrame)*mapping(:1 ,:2); # 这里设置为虚线,可选值还有:dot点线、:dashdot点虚线等 graphLayers = linear() * style(linestyle=:dash); plotMainGraph = mainGraphData*graphLayers; returnPlot = draw(plotMainGraph)
方式二:在draw阶段全局调整样式
如果需要统一设置绘图中所有线性拟合线的样式,也可以在draw()函数里传入theme参数:
returnPlot = draw(plotMainGraph; theme=Theme(AlgebraOfGraphics=(line=(linestyle=:dot,),)))
常用linestyle可选值
:solid:实线(默认):dash:虚线:dot:点线:dashdot:点虚线:dashdotdot:双点虚线
内容的提问来源于stack exchange,提问作者Mstislav Keldysh
相关产品推荐
相关产品推荐

