简介

一、基础教程

1. 使用DataFrame数据进行绘制

2. 使用数组数据进行绘制

3. 图形美学

4. 影调范围(Scale)

二、进阶教程

1. 绘图

2. 几何结构(Geometries)

3. 指南(Guides)

4. 统计数据(Statistics)

5. 坐标(Coordinates)

6. 范围(Scales)

7. 形状(Shape)

8. 合成(Compositing)

9. 主题(Theme)


简介

Gadfly 是一个用Julia编写的绘图和可视化系统,可将生成的图形渲染成SVG、PNG、Postscript和PDF格式(Gadfly 支持通过Compose.jl中的原生 Julian 渲染器创建开箱即用的 SVG 图像。PNG、PDF、PS 和 PGF 格式需要 Julia 安装 Cairo.jl 和 Fontconfig.jl 才可以使用。),由Snap.svg提供的互动性,如平移、缩放、切换,与DataFrames.jl紧密结合。Gadfly 是 Julia 的“图形语法”风格统计图形系统的实现。Gadfly 可以处理作为DataFrame或普通数组提供的数据。

一、基础教程

using Gadfly# 设置图形大小默认值
set_default_plot_size(6inch, 4inch)# 绘制散点图
p1 = plot(y = rand(100))
p2 = plot(x=collect(1:100), y=rand(100), Guide.xlabel("x轴"), Guide.ylabel("y轴"), Geom.point)# 绘制折线图
p3 = plot(x=collect(1:100), y=rand(100), Guide.xlabel("x轴"), Guide.ylabel("y轴"), Geom.line)# 绘制多个图层
x = collect(1:100)  # 自变量范围
y1(x) = sin(x)  # 函数1
y2(x) = cos(x)  # 函数2
layer1 = layer(x=x,y=sin.(x),Geom.point)  # 图层1
layer2 = layer(x=x,y=cos.(x),Geom.point)  # 图层2
p3 = plot(layer1,layer2)# 绘制不同风格的的图形
x = collect(0:0.01:10*pi)  # 自变量范围
plot(x=x,y=sin.(x),Geom.point,Geom.line)# 保存图片
draw(SVG("myplot1.svg", 15cm, 9cm), p1)
draw(SVG("myplot2.svg", 15cm, 9cm), p2)
draw(SVG("myplot3.svg", 15cm, 9cm), p3)
img = SVG("iris_plot.svg", 14cm, 8cm)  # 保存当前图片

1. 使用DataFrame数据进行绘制

基本调用方法为:plot(data::AbstractDataFrame, elements::Element...; mapping...)

注:默认使用列名作为坐标轴标签

using Gadfly, RDatasets
iris = dataset("datasets", "iris")
p = plot(iris, x=:SepalLength, y=:SepalWidth, Geom.point)
img = SVG("iris_plot.svg", 14cm, 8cm)  # 设置图片大小
draw(img, p)  # 绘制图形

2. 使用数组数据进行绘制

基本调用方法:plot(elements::Element...; aesthetics...)    使用关键字参数直接提供要绘制的数据

using Gadflyplot(x = [v for v in 1:100],y = rand(100),Geom.point,Theme(background_color="white"),
)

3. 图形美学

plot(iris, x=:SepalLength, y=:SepalWidth, color=:Species, Geom.point);# or equivalently for Arrays:
Color = iris.Species   # 不同的Species显示不同的颜色
plot(x=SepalLength, y=SepalWidth, color=Color, Geom.point,Guide.xlabel("SepalLength"), Guide.ylabel("SepalWidth"),Guide.colorkey(title="Species"))

4. 影调范围(Scale)

所有的美学都有一个调节范围,例如Scale.x_continuous(),有些有一个Guide,例如Guide.xticks()。Scale可以是连续的或离散的。有些Scale在Theme()中也有一个相应的调色板。

如果不提供Scales或Guide,Gadfly将作出有根据的猜测。

4.1 Continuous Scales

例如: Scale.x_continuous(format= , minvalue= , maxvalue= )
format 可以是: :plain, :scientific, :engineering, or :auto.

set_default_plot_size(21cm ,8cm)
mammals = dataset("MASS", "mammals")
p1 = plot(mammals, x=:Body, y=:Brain, label=:Mammal, Geom.point, Geom.label)
p2 = plot(mammals, x=:Body, y=:Brain, label=:Mammal, Geom.point, Geom.label,Scale.x_log10, Scale.y_log10)  # 采用对数坐标
hstack(p1, p2)

比例转换包括用于X、Y、颜色美学的_sqrt、_log、_log2、_log10、_asinh,以及用于尺寸美学的_area。

using Printf
Diamonds = dataset("ggplot2","diamonds")
p3= plot(Diamonds, x=:Price, y=:Carat, Geom.histogram2d(xbincount=25, ybincount=25),Scale.x_continuous(format=:engineering) )
p4= plot(Diamonds, x=:Price, y=:Carat, Geom.histogram2d(xbincount=25, ybincount=25),Scale.x_continuous(format=:plain),Scale.y_sqrt(labels=y->@sprintf("%i", y^2)),Scale.color_log10(minvalue=1.0, maxvalue=10^4),Guide.yticks(ticks=sqrt.(0:5)) )
hstack(p3, p4)

4.2 Discrete Scales

例如:Scale.shape_discrete(labels= , levels= , order= )

mtcars = dataset("datasets","mtcars")
labeldict = Dict(4=>"four", 6=>"six", 8=>"eight")
p5 = plot(mtcars, x=:Cyl, color=:Cyl, Geom.histogram,Scale.x_discrete(levels=[4,6,8]), # 更改X轴坐标值Scale.color_discrete(levels=[4,6,8]) # 更改默认的图形显示颜色
)
p6 = plot(mtcars, x=:Cyl, color=:Cyl, Geom.histogram,Scale.x_discrete(labels=i->labeldict[i], levels=[8,6,4]),  # 更改X轴坐标值Scale.color_discrete(levels=[8,6,4]) )  # 更改默认的图形显示颜色
hstack(p5, p6)  # 将两个图水平堆积

对于带有主题调色板的离散比例,级别的顺序和主题调色板的顺序相匹配。

x, y = 0.55*rand(4), 0.55*rand(4)
plot( Coord.cartesian(xmin=0, ymin=0, xmax=1.0, ymax=1.0), # 坐标轴取值范围layer(x=x, y=y, shape=["A"], alpha=["day","day","day","night"]),layer(x=1.0.-y[1:3], y=1.0.-x[1:3], shape=["B", "C","C"], alpha=["night"]),Scale.shape_discrete(levels=["A","B","C"]),Scale.alpha_discrete(levels=["day","night"]),Theme(discrete_highlight_color=identity, point_size=12pt,point_shapes=[Shape.circle, Shape.star1, Shape.star2], alphas=[0, 1.0],default_color="midnightblue" )
)

5. 保存图片

保存为SVG格式

p = plot(...)# 方式一
draw(SVG("foo.svg"), p)
# 方式二
draw(SVG("foo.svg", 6inch, 4inch), p)

保存为其他格式(需借助Cairo.jl和Fontconfig.jl包)

draw(SVGJS("foo1.svg", 6inch, 6inch), p)
draw(PNG("foo2.svg", 6inch, 6inch), p)
draw(PDF("foo3.svg", 6inch, 6inch), p)
draw(PGF("foo4.svg", 6inch, 6inch), p)
draw(PS("foo5.svg", 6inch, 6inch), p)

二、进阶教程

1. 绘图

与Gadfly的大部分互动是通过 plot() 函数。绘图是通过将数据绑定到美学上,并指定一些元素,包括Scales, Coordinates, Guides, and Geometries。美学是一组特殊的命名变量,它被映射到一个几何体上,这种映射如何发生是由元素定义的。

除了在前面的描述中提到在DataFrames和Arrays上操作的标准绘图方法外,Gadfly还有一些特殊的签名,使绘制函数和表达式更加方便。

plot(f::Function, lower, upper, elements...; mapping...)
plot(fs::Vector{T}, lower, upper, elements...; mapping...) where T <: Base.Callable
plot(f::Function, xmin, xmax, ymin, ymax, elements...; mapping...)
spy(M::AbstractMatrix, elements...; mapping...) -> Plot

例如:

push!()函数可用于逐步添加小部件。

例如:

Gadfly也可以同时绘制多组数据,例子如下:

方法 说明
display(p::Plot) 将p渲染到一个多媒体显示器上,通常是互联网浏览器。
push!(p::Plot, element::ElementOrFunctionsOrLayers) 将一个元素、函数或图层添加到图表中。元素包括Coordinates, Geometries, Guides, Scales, Statistics, 和 Themes。
draw(backend::Compose.Backend, p::Plot) Compose.draw的一个简捷版本,无需调用render。
gridstack(ps::Matrix{Union{Plot,Context}}) 将图表排列成一个矩形阵列。使用context()作为一个空面板的占位符。异质矩阵必须是类型化的。另见hstack和vstack。

2. 几何结构(Geometries)

几何结构负责实际的绘制工作。一个几何体接受一个或多个美学元素作为输入,并使用与这些美学元素绑定的数据来绘制东西。例如,Geom.point几何体使用x和y美学来绘制点,而Geom.line几何体则使用这两种美学来绘制线。

核心几何结构用法 说明
Geom.abline[(; color=nothing, size=nothing, style=nothing)] 绘制直线T(y)=斜率*T(x)+截距,其中T(⋅)默认为同一函数。如果没有指定,截距默认为[0],斜率默认为[1]。
Geom.bar[(; position=:stack, orientation=:vertical)] 绘制以x为中心的高度为y的条形图,或者从xmin到xmax的位置。如果方向是:horizontal,则用x换成y。如果位置是:stack,它们将被放置在彼此的上面;如果是:dodge,它们将被并排放置。关于标记躲避或堆叠的条形图,见Stat.dodge。如果位置是:identity,那么条形图可以重叠(使用alpha美学)。
Geom.beeswarm[; (orientation=:vertical, padding=0.1mm)]
Geom.blank 绘制空白图形。
Geom.boxplot[(; method=:tukey, suppress_outliers=false)]
Geom.errorbar
Geom.hexbin[(; xbincount=200, ybincount=200)]
Geom.hline[(; color=nothing, size=nothing, style=nothing)]
Geom.label[(; position=:dynamic, hide_overlaps=true)]
Geom.line[(; preserve_order=false, order=2)]
Geom.point 散点图
Geom.polygon[(; order=0, fill=false, preserve_order=false)]
Geom.rectbin
Geom.ribbon[(; fill=true)]
Geom.segment[(; arrow=false, filled=false)]
Geom.subplot_grid[(elements...)] 共享某个轴
Geom.violin[(; order=1)]
Geom.vline[(; color=nothing, size=nothing, style=nothing)]
Geom.xerrorbar
Geom.yerrorbar

衍生的几何结构通过自动应用默认的统计量建立在核心几何图形之上。

衍生的几何结构用法 说明
Geom.band[(; orientation=:vertical)]
Geom.contours[(; levels=15, samples=150, preserve_order=true)]
Geom.density[(; bandwidth=-Inf)]
Geom.density2d[(; bandwidth=(-Inf,-Inf), levels=15)]
Geom.ellipse[(; distribution=MvNormal, levels=[0.95], nsegments=51, fill=false)]
Geom.hair[(; intercept=0.0, orientation=:vertical)]
Geom.hband
Geom.histogram[(; position=:stack, bincount=nothing, minbincount=3, maxbincount=150, orientation=:vertical, density=false, limits=NamedTuple())]
Geom.histogram2d[(;xbincount=nothing,xminbincount=3,xmaxbincount=150,                                 ybincount=nothing, yminbincount=3, ymaxbincount=150)]
Geom.path
Geom.rect
Geom.smooth[(; method:loess, smoothing=0.75)]
Geom.step[(; direction=:hv)]
Geom.vband[()]
Geom.vector[(; filled=false)]
Geom.vectorfield[(; smoothness=1.0, scale=1.0, samples=20, filled=false)]

3. 指南(Guides)

与 "几何结构 "非常相似的是 "Guides,它绘制支持实际可视化的图形,如轴刻度、轴标签和颜色键。主要的区别是,几何体总是在矩形图框内绘制,而指南有一些特殊的布局考虑。

属性 用法
Guide.annotation

Guide.annotation(ctx::Compose.Context)

用一个任意的 Compose 图形叠加一个绘图。上下文将继承绘图的坐标系统,除非用自定义的单位框重写。

Guide.colorkey

Guide.colorkey[(; title=nothing, labels=nothing, pos=nothing)] Guide.colorkey(title, labels, pos)

启用对自动生成的彩色键的控制。pos覆盖Theme(key_position=),可以是相对坐标(如[0.7w, 0.2h]是右下角象限),绝对坐标(如[0mm, 0mm]),或绘图比例坐标(如[0,0])。

Guide.shapekey

Guide.shapekey[(; title="Shape", labels=String[], pos=Float64[])] Guide.shapekey(title, labels, pos)

启用对自动生成的形状键的控制。pos覆盖了Theme(key_position=),可以是相对坐标(例如[0.7w, 0.2h]是右下象限)、绝对坐标(例如[0mm, 0mm])或绘图比例坐标(例如[0,0])。Guide.shapekey(nothing)将隐藏该键。

Guide.sizekey[(; title="size", labels=String[], pos=[])]
Guide.sizekey(title, labels, pos)
Guide.title

Guide.title(title)

设置plot的标题

Guide.xlabel

Guide.xlabel(label, orientation=:auto)

设置绘图的 x 轴标签。 label是 aStringnothingorientation也可以是:horizontalor :vertical

Guide.xrug Guide.xrug
Guide.xticks

Guide.xticks[(; label=true, ticks=:auto, orientation=:auto)] Guide.xticks(label, ticks, orientation)

格式化 x 轴的刻度线和标签。 label切换标签可见性。 ticks也可以是位置数组,或nothingorientation也可以是:horizontalor :vertical

Guide.ylabel

Guide.ylabel(label, orientation=:auto)

设置绘图的 y 轴标签。 labelStringnothingorientation也可以是:horizontalor :vertical

Guide.yrug Guide.yrug
Guide.yticks

Guide.yticks[(; label=true, ticks=:auto, orientation=:horizontal)] Guide.yticks(ticks, label, orientation)

格式化 y 轴的刻度线和标签。 label切换标签可见性。 ticks也可以是位置数组,或nothingorientation也可以是:autoor :vertical

Guide.manual_color_key

Guide.manual_color_key(title::String,labels::Vector{String},color::AbstractVector= 1:length(labels); pos=[], shape=Function[],size=Measure[])

Guide.manual_discrete_key Guide.manual_discrete_key(title::String,labels::Vector{String};pos[],color=Colorant[], shape=Function[], size=Measure[])

4. 统计数据(Statistics)

Statistics是将一个或多个美学作为输入,对这些值进行操作,然后输出到一个或多个美学的函数。

例如,绘制boxplots通常使用boxplot statistic(Stat.boxplot),它将x和y美学作为输入,并输出中间、上下铰链和上下栅栏美学。

Stat.band[(; orientation=:vertical)]
Stat.bar[(; position=:stack, orientation=:vertical)]
Stat.binmean[(; n=20)]
Stat.boxplot[(; method=:tukey)]
Stat.contour[(; levels=15, samples=150)]
Stat.density[(; n=256, bandwidth=-Inf)]
Stat.density2d[(; n=(256,256), bandwidth=(-Inf,-Inf), levels=15)]
Stat.dodge[(; position=:dodge, axis=:x)]
Stat.ellipse[(; distribution=MvNormal, levels=[0.95], nsegments=51)]
Stat.func[(; num_samples=250)]
Stat.hair[(; intercept=0.0, orientation=:vertical)]
Stat.hexbin[(; xbincount=50, ybincount=50)]
Stat.histogram[(; bincount=nothing, minbincount=3, maxbincount=150, position=:stack, orientation=:vertical, density=false, limits=NamedTuple())]
Stat.histogram2d[(; xbincount=nothing, xminbincount=3, xmaxbincount=150, ybincount=nothing, yminbincount=3, ymaxbincount=150)]
Stat.identity
Stat.Nil
Stat.qq
Stat.quantile_bars[(; quantiles=[0.025, 0.975], bar_width=0.1, n=256, bandwidth=-Inf)]

Stat.rectbin

Stat.smooth[(; method=:loess, smoothing=0.75, levels=[0.95])]

Stat.step[(; direction=:hv)]

Stat.vectorfield[(; smoothness=1.0, scale=1.0, samples=20)]

Stat.violin[(n=300)]

_calculate_quantile_bar(stat::QuantileBarsStatistic, aes)

Stat.x_jitter[(; range=0.8, seed=0x0af5a1f7)]

Stat.xticks[(; ticks=:auto, granularity_weight=1/4, simplicity_weight=1/6, coverage_weight=1/3, niceness_weight=1/4)]

Stat.y_jitter[(; range=0.8, seed=0x0af5a1f7)]

Stat.yticks[(; ticks=:auto, granularity_weight=1/4, simplicity_weight=1/6, coverage_weight=1/3, niceness_weight=1/4)]

5. 坐标(Coordinates)

调用方法 说明

Coord.cartesian(; xmin=nothing,xmax=nothing,

ymin=nothing, ymax=nothing,

xflip=false, yflip=false,

aspect_ratio=nothing, fixed=false, raster=false)

xmin、xmax、ymin和ymax指定了x轴和y轴上的硬性最小值和最大值,并覆盖Scale.x_continuous和Scale.y_continuous中的软性限制。如果xflip或yflip为true,则各自的轴将被翻转。aspect_ratio如果不是nothing,就会履行它的名字,除非被一个固定的值true所覆盖,在这种情况下,长宽比会跟随绘图的单位(例如,如果y轴是5个单位高,x轴是10个单位宽,绘图的长宽比将是2)。

6. 范围(Scales)

Scales 与Statistics类似,对原始数据应用转换,通常将一种美学映射到相同的美学,同时保留原始值。

例如,Scale.x_log10 美学在应用 log10 转换后将美学映射 xx美学,但会跟踪原始值以便正确识别数据点。

类型或函数 说明
color_identity
label
alpha_continuous[(; minvalue=0.0, maxvalue=1.0, labels=nothing, format=nothing, minticks=2, maxticks=10, scalable=true)]
alpha_discrete[(; labels=nothing, levels=nothing, order=nothing)]
color_asinh[(; minvalue=nothing, maxvalue=nothing, colormap)]
color_continuous[(; minvalue=nothing, maxvalue=nothing, colormap)] 通过将颜色美学映射到颜色,创建一个连续的色标。minvalue和maxvalue指定对应于色标底部和顶部的数据值。colormap是一个定义在0到1区间的函数,返回一个颜色。也请参见lab_gradient。
color_discrete_hue[(f; levels=nothing, order=nothing, preserve_order=true)] 创建一个离散的色标,将色彩美学中的分类等级映射到颜色上。
color_discrete_manual(colors...; levels=nothing, order=nothing) 与color_discrete_hue类似,只是每个级别的颜色是直接指定的,而不是由一个函数计算的。
color_log[(; minvalue=nothing, maxvalue=nothing, colormap)]
color_log10[(; minvalue=nothing, maxvalue=nothing, colormap)]
color_log2[(; minvalue=nothing, maxvalue=nothing, colormap)]
color_sqrt[(; minvalue=nothing, maxvalue=nothing, colormap)]
group_discrete[(; labels=nothing, levels=nothing, order=nothing)]
lab_gradient(cs...) 可以应用于其他类型,例如Scale.lab_gradient("blue", "ghostwhite", "red")。
lab_gradient(cs::Color...) 生成一个函数f(p),在n≥2种颜色之间创建一个梯度,其中0≤p≤1。如果你有一个颜色的集合,那么就使用splitting操作符......。
Scale.lab_gradient(range(HSV(0,1,1), stop=HSV(250,1,1), length=100)...)
lab_rainbow(l, c, h0, n)

7. 形状(Shape)

函数 说明
Gadfly.Shape.cross(xs, ys, rs) 在指定的坐标处绘制大小为rs的十字。
Gadfly.Shape.diamond(xs, ys, rs) 在指定的坐标处绘制大小为rs的菱形。
Gadfly.Shape.dtriangle(xs, ys, rs) 在指定的坐标处绘制大小为rs的向下倾斜的三角形。
Gadfly.Shape.hexagon(xs, ys, rs) 在指定的坐标处绘制大小为rs的六边形。
Gadfly.Shape.hline(xs, ys, rs) 在指定的坐标处绘制大小为rs的水平线。
Gadfly.Shape.ltriangle(xs, ys, rs, scalar=1) 在指定的坐标处绘制大小为rs的向左倾斜的三角形。
Gadfly.Shape.octagon(xs, ys, rs) 在指定的坐标处绘制大小为rs的八边形。
Gadfly.Shape.rtriangle(xs, ys, rs) 在指定的坐标处绘制大小为rs的直角三角形 。
Gadfly.Shape.square(xs, ys, rs) 在指定的坐标处绘制大小为rs的正方形。
Gadfly.Shape.star1(xs, ys, rs, scalar=1) 在指定的坐标处绘制大小为rs的五角星。
Gadfly.Shape.star2(xs, ys, rs, scalar=1) 在指定的坐标处绘制大小为rs的四角星。
Gadfly.Shape.utriangle(xs, ys, rs) 在指定的坐标处绘制大小为rs的向上倾斜的三角形。
Gadfly.Shape.vline(xs, ys, rs) 在指定的坐标处绘制大小为rs的垂直线。
Gadfly.Shape.xcross(xs, ys, rs) 在指定的坐标处绘制大小为rs的旋转的十字。

8. 合成(Compositing)

Gadfly支持先进的图形构成技术,如构面、堆叠和分层。

8.1 构面

Geom.subplot_grid同样可以垂直排列图块,如果有两个共享轴,甚至可以在二维网格中排列。

子图有一些内部和外部元素,包括Guides和Scales。例如,将guide放在Geom.subplot_grid(...)里面,以改变子图的标签,或放在外面以改变外图的标签。

8.2 堆叠

为了合成来自不同数据集的图,或者相同数据但不同轴的图,需要使用一个声明性接口。教程中展示了如何用hstack来水平排列这些不同的图。这里我们说明如何用vstack将它们垂直堆叠起来,或者用gridstack将它们安排在一个网格中。与Geom.subplot_grid相比,这些命令允许在刻度线、坐标轴标签和其他绘图细节方面进行更多的定制。

theme1 = Theme(key_position=:none)
fig1a = plot(iris, x=:SepalLength, y=:SepalWidth, color=:Species, theme1,alpha=[0.6], size=:PetalLength, Scale.size_area(maxvalue=7))
fig1b = plot(iris, x=:SepalLength, color=:Species, Geom.density,Guide.ylabel("density"), Coord.cartesian(xmin=4, xmax=8), theme1)
vstack(fig1a,fig1b)

hstack和vstack可以被组合,以创建任意的面板排列。例如:

vstack(hstack(p1,p2),hstack(p3,p4,p5))

如果所有行或列都有相同数量的面板,使用gridstack是最简单的。

gridstack([p1 p2; p3 p4])

对于这些命令中的每一条,你都可以通过传递一个空的plot()来让面板空白。其他元素,例如Scales和Guides,可以被添加到空白图中。如果绘图包含美学映射,请使用Geom.blank。

using Compose # for w, h relative units
fig1c = plot(iris, x=:SepalWidth, color=:Species, Geom.density,Guide.ylabel("density"), Coord.cartesian(xmin=2, xmax=4.5), theme1)
fig1d = plot(iris, color=:Species, size=:PetalLength, Geom.blank,Scale.size_area(maxvalue=7), Theme(key_swatch_color="silver"),Guide.colorkey(title="Species", pos=[0.55w,-0.15h]),  # 以宽度和高度为相对单位Guide.sizekey(title="PetalLength (cm)", pos=[0.2w, -0.10h]))
gridstack([fig1a fig1c; fig1b fig1d])

title(hstack(p1,p2), "My creative title")  可给整个图形添加一个标题

8.3 图层

通过输入图层对象给plot,在同一个图上绘制多个图层。

 layer() 可以输入:Geometries, Statistics, and Themes, 但不能输入 Scales, Coordinates, or Guides.

9. 主题(Theme)

许多控制绘图外观的参数可以向plot函数传递一个Theme对象来重写,或者使用push_theme或with_theme将Theme设置为当前主题。

Theme的构造函数需要零个或多个关键字参数,每个参数都会覆盖相应字段的默认值。关键字的完整列表见Theme。

# Measure可使用的的单位包括mm、cm、inch、pt
julia> len = 1mm
1.0mm# Color可使用的格式如下:
colorant"red"
colorant"#FF0000"
colorant"rgb(255,0,0)"
colorant"hsl(120, 100%, 25%)
colorant"hsla(120, 100%, 25%, 0.6)"
# 也可直接使用命名颜色,例如:"white"、"red"、"azure"等
关键字参数 说明
default_color 如果颜色审美没有被映射到任何东西上,这就是被使用的颜色。(Color)
point_size 在点、boxplot和beeswarm几何图形中的点的大小。(Measure)
point_size_min 点几何中点的最小尺寸。(Measure)
point_size_max 点几何中点的最大尺寸。(Measure)
discrete_sizemap Scale.size_discrete2中的函数f。
continuous_sizemap Scale.size_radius和Scale.size_area中的函数f。
discrete_colormap 一个新的主题字段,正在开发中。目前只适用于Guide.manual_discrete_key和Guide.manual_color_key。(Function)
point_shapes

点几何中的点的形状。(circle, square, diamond, cross, xcross, utriangle, dtriangle, star1, star2, hexagon, octagon, hline, vline, ltriangle, rtriangle 中的函数)

line_width 线条几何中的线的宽度。(Measure)
line_style 线条几何中的线条样式。默认调色板是[:solid, :dash, :dot, :dashdotdot, :ldash, :ldashdash, :ldashdot],它是一个Vector{Symbol},或者使用Vector{<:Measure}定制。
alphas 阿尔法调色板。默认调色板是[1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.0]。使用长度为1或更大的矢量进行定制,0.0≤值≤1.0
panel_fill 主绘图板中使用的背景颜色。(Color or Nothing)
panel_stroke 主绘图板的边框颜色。(Color or Nothing)
panel_line_width 主绘图板的边界线宽度。(Measure)
panel_opacity 绘图背景板的不透明度。(Float in [0.0, 1.0])
background_color 整个绘图的背景颜色。如果没有,就没有背景。(Color or Nothing)
plot_padding 围绕绘图的填充。填充的顺序是: plot_padding=[左,右,上,下]。如果提供了一个长度为1的矢量,例如[5mm],那么这个值将应用于所有的边。可以使用绝对或相对单位。(Vector{<:Measure})
grid_color 网格线的颜色。(Color or Nothing)
grid_line_style 网格线的样式。(包括 :solid, :dash, :dot, :dashdot, :dashdotdot, or Vector of Measures)
grid_color_focused 在D3后端,用鼠标在图上划一下,网格线就会过渡到这种颜色而得到强调。(Color or Nothing)
grid_line_width 网格线的宽度。(Measure)
grid_line_order 网格线的上下文顺序(默认=0)。绘图板背景的上下文顺序为-1。 (Int)
minor_label_font 次要标签的字体,如tick labels 和 entries in keys。(String)
minor_label_font_size 次要标签的字体大小。(Measure)
minor_label_color 次要标签的颜色。(Color)
major_label_font 主要标签的字体,如guide标题和轴标签。(String)
major_label_font_size 主要标签的字体大小。(Measure)
major_label_color 主要标签的颜色。(Color)
point_label_font Geom.label中标签的字体。(String)
point_label_font_size labels的字体大小。(Measure)
point_label_color labels的颜色。(Color)
key_title_font 键标题的字体。(String)
key_title_font_size 键标题的字体大小。(Measure)
key_title_color 键标题的颜色。(Color)
key_label_font 键入标签的字体。(String)
key_label_font_size 键入标签的字体大小。(Measure)
key_label_color 键入标签的字体颜色。(Color)
key_color_gradations 在一个连续的色键中要显示多少个梯度。(Int)
bar_spacing Geom.bar中条的间距。(Measure)
boxplot_spacing Geom.boxplot中箱线图的间距。(Measure)
errorbar_cap_length error bar中caps的长度。(Measure)
stroke_color
highlight_width 几何图形(如points和boxplot rectangles)边缘线条宽度。(Measure)
discrete_highlight_color 用于勾勒绘图几何体的颜色。这是一个改变几何体填充颜色的函数(例如darkens)。(Function)
continuous_highlight_color 用于勾勒绘图几何体的颜色。这是一个改变几何体填充颜色的函数(例如darkens)。(Function)
lowlight_color 用于绘制背景几何体的颜色,如Geom.ribbon和Geom.polygon。这是一个改变几何体填充颜色的函数。(Function)
middle_color 改变颜色的函数,用于在boxplots中绘制中线。(Function)
middle_width boxplots中线的宽度。(Measure)
guide_title_position 色键guides标题的位置的::center, :right。(Symbol)
colorkey_swatch_shape 色键guide中色块的形状。可以是::circle or :square (Symbol)。
key_swatch_shape 用于色板按键的形状(功能与point_shapes相同)。
key_swatch_color 在色板的键中使用的默认颜色。目前适用于Guide.shapekey和Guide.sizekey(Color)。
key_swatch_size 关键色块的大小,将覆盖Theme(point_size=)。目前适用于Guide.shapekey(Measure)。
key_position 键应该放在相对于绘图板的位置。可以选择:left, :right, :top, :bottom, :inside 或 :none。设置为 :none 会使按键失效。设置为 :inside 将按键放置在绘图的右下角。(Symbol)
bar_highlight 用于在柱状图中描画柱状图的颜色。如果给定了一个函数,它将用于转换条形图的填充颜色,以获得笔画颜色。 (Function, Color, or Nothing)
rug_size
label_placement_iterations 退火迭代的次数。用于Geom.label(position=:dynamic)。
label_out_of_bounds_penalty 对不包含在绘图框架内的标签的惩罚。用于Geom.label(position=:dynamic)。
label_hidden_penalty 使标签隐藏以避免重叠的惩罚。用于Geom.label(position=:dynamic)。
label_visibility_flip_pr 在标签布局中提出可见性翻转的概率。用于Geom.label(position=:dynamic)。
label_padding 标记和标签之间的填充。用于Geom.label(position=:dynamic)。
key_max_columns 键入标签的最大列数。(Int)
discrete_color_scale 一个离散的颜色刻度见Scale.color_discrete_hue
continuous_color_scale 一个连续的颜色刻度见Scale.color_continuous

9.1 The Theme stack

push_theme(t::Theme)和pop_theme()将分别从这个栈中推送和弹出。你也可以使用with_theme(f, t::Theme)来临时设置一个主题作为当前的主题,并调用函数f,它可以在其他地方定义,也可以匿名,或者作为一个do-block。

9.2 style

你可以使用style来覆盖当前主题的字段。与Theme的构造函数一样,style输入关键字参数,返回一个Theme,并可以与push_theme、with_theme和plot一起使用。

9.3 Named themes

要通过名字注册一个主题,你可以扩展Gadfly.get_theme(::Val{:theme_name})来返回一个Theme对象。

Gadfly内置了两个命名的主题  :default 和:dark

参考资源:Home · Gadfly.jl

Julia数据可视化:Gadfly.jl包的使用相关推荐

  1. 在R、Python和Julia中常用的数据可视化技术

    俗话说"一图胜千言".通过各种图片和图形化展示,我们可以更清晰地表达很多抽象概念.理论.数据模式或某些想法.在本章中,我们首先解释为什么应该关心数据可视化.然后,我们将讨论几种在R ...

  2. 每日一课 | Python数据可视化—如何做好启动准备(小白必读)

    03 大家好,我是营长,昨天营长分享了数据科学"的基本概念,不清楚的小伙伴可戳这????每日一课|案列上手Python数据可视化 本期营长接着为大家分享Python数据可视化相关内容 这期分 ...

  3. 2022-11-28-大数据可视化“可视化国产/进口电影票房榜单”分析,特征维度大于50

    可视化国产/进口电影票房榜单 前言 数据分析 数据可视化过程 分析总结 前言 党的十八大以来,国产电影产业与事业快速发展,创作水平不断提高,题材类型丰富多元,受众口碑不断提升,在市场竞争中表现愈发突出 ...

  4. python数据动态可视化进阶版,Matplotlib Animations 数据可视化进阶

    原标题:Matplotlib Animations 数据可视化进阶 如果你对我的代码有兴趣,可以在我的GitHub查看.当你第一次执行时,代码会报错(我一直没有解决),但是同样的代码框再执行一次,就能 ...

  5. karyoploteR: 基因组数据可视化 R 包

    karyoploteR,是一个适用于所有基因组数据(any data on any genome)非圆环布局(non-circular layouts)的可视化 R/Bioconductor 包.开发 ...

  6. R语言使用gt包和gtExtras包优雅地、漂亮地显示表格数据:使用gt包可视化表格数据,使其易于阅读和理解、使用gtExtras包添加一个图,显示表中某一列中的数字

    R语言使用gt包和gtExtras包优雅地.漂亮地显示表格数据:使用gt包可视化表格数据,使其易于阅读和理解.使用gtExtras包添加一个图,显示表中某一列中的数字 目录

  7. R语言使用gt包和gtExtras包优雅地、漂亮地显示表格数据:使用gt包可视化表格数据,使其易于阅读和理解、使用gtExtras包添加一个图,显示表中某一列中的数字、并为类型数据添加图像符号标签

    R语言使用gt包和gtExtras包优雅地.漂亮地显示表格数据:使用gt包可视化表格数据,使其易于阅读和理解.使用gtExtras包添加一个图,显示表中某一列中的数字.并为类型数据添加图像符号标签 目 ...

  8. R语言层次聚类(hierarchical clustering):数据缩放、PCA聚类结果可视化、fpc包的clusterboot函数通过bootstrap重采样的方法评估hclust层次聚类的稳定性

    R语言层次聚类(hierarchical clustering):数据缩放.PCA聚类结果可视化.fpc包的clusterboot函数通过bootstrap重采样的方法评估hclust层次聚类的稳定性 ...

  9. 原创 | R的基础及进阶数据可视化功能包介绍

    R 作为入门级编程语言,被经常运用在数据整理.数据可视化.以及机器学习中. 本篇文章将主要介绍在R中如何可视化数据 (基础+进阶). R绘图的原理 使用R绘图,我们需要在脑海中明确几个必要元素.首先, ...

最新文章

  1. win10内建子系统Linux
  2. Linux上使用find、xargs、grep递归的查找指定文件类型中的内容
  3. One Day-XML:XSLT
  4. “约见”面试官系列之常见面试题之第一百零六篇之css只在当前组件中起作用(建议收藏)
  5. ITTC数据挖掘平台介绍(综述)——平台简介
  6. 模拟进程创建、终止、阻塞、唤醒原语_操作系统第二章--进程的描述与控制
  7. centOS 6.0无法运行dump指令的解决方法
  8. 文件正由另一进程使用,该进程无法访问该文件,解决方法
  9. Unable to find the requested .Net Framework Data Provider
  10. 社区发现(三)--CMP
  11. 【基础数据库】经济行业分类
  12. 简易旋转倒立摆设计报告
  13. pycharm免安装版推荐
  14. html的color粉颜色,HTML颜色一览(color)
  15. 携职教育:个税APP申报流程
  16. 对于硬件成品测试,可以设计哪些测试用例?
  17. Android合并音频文件
  18. 自控力极差的人如何自救?
  19. 渝粤题库 陕西师范大学 《教育法学》作业
  20. 作为一名项目管理人,这几款软件帮了我很多

热门文章

  1. 卸载cuda,以及N卡驱动
  2. 第三章:密码学基本理论
  3. hdu2822(会双搜后再写次)
  4. 如何批量压缩pdf文件到最小
  5. 时下最火的网络视频编码器传输技术
  6. 各国语言名称英文简写对照表
  7. 一般人看不透!沉默的大多数用户才是产品发展的关键!
  8. Android 名词解释
  9. Flink DataStream Split 实现分流
  10. 4.22 虾皮_小米_度小满