Qu

Uncategorised

qu_plot_types

Every kind of plot Qu draws, one panel each.

catalog/qu_plot_types.qu

The third sheet in the reference set, after `qu_markers.qu` (every glyph) and `qu_line_styles.qu` (every line style). This one answers a different question: not "what can a series look like" but "what SHAPE of picture can I ask for", which is the thing you want to see all at once when choosing how to show a result.

Each panel is the smallest honest example of its type -- real data, real axes, no decoration beyond what the type itself needs.

Run: qu run catalog/qu_plot_types.qu

Results

printed
wrote qu_plot_types.svg and .pdf
-0.8 -0.4 0 0.4 0.8 0 2 4 6 8 10 plot -0.8 -0.4 0 0.4 0.8 0 2 4 6 8 10 x=0, y=0 x=0.909, y=0.789 x=1.818, y=0.97 x=2.727, y=0.403 x=3.636, y=-0.475 x=4.545, y=-0.986 x=5.455, y=-0.737 x=6.364, y=0.08 x=7.273, y=0.836 x=8.182, y=0.947 x=9.091, y=0.328 x=10, y=-0.544 scatter -0.8 -0.4 0 0.4 0.8 0 2 4 6 8 10 stem -0.8 -0.4 0 0.4 0.8 0 2 4 6 8 10 stair / step 0 0.4 0.8 1.2 1.6 2.0 2.4 0 2 4 6 8 10 area -1.0 -0.5 0 0.5 1.0 0 2 4 6 8 10 fill_between 0 1 2 3 4 5 6 7 A B C D x=0, y=4 x=1, y=7 x=2, y=3 x=3, y=6 bar 0 1 2 3 4 5 6 7 8 A B C D stackbar 0 1 2 3 4 5 6 7 A B C D groupbar 0 40 80 120 160 -2 0 2 x=-3.414, y=2 x=-3.179, y=1 x=-2.943, y=3 x=-2.708, y=9 x=-2.473, y=5 x=-2.237, y=6 x=-2.002, y=25 x=-1.767, y=35 x=-1.532, y=47 x=-1.296, y=92 x=-1.061, y=104 x=-0.826, y=130 x=-0.59, y=177 x=-0.355, y=159 x=-0.12, y=181 x=0.115, y=179 x=0.351, y=177 x=0.586, y=168 x=0.821, y=130 x=1.057, y=104 x=1.292, y=92 x=1.527, y=62 x=1.763, y=41 x=1.998, y=33 x=2.233, y=16 x=2.468, y=13 x=2.704, y=5 x=2.939, y=0 x=3.174, y=3 x=3.41, y=1 hist -4 -3 -2 -1 0 1 2 3 4 0 1 2 boxplot -1.2 -0.8 -0.4 0 0.4 0.8 1.2 0 2 4 6 8 10 errorbar -40 -35 -30 -25 -20 -15 -10 -5 0 1 10 100 1000 10000 semilogx 0.0001 0.0010 0.0100 0.1000 1.0000 1 10 100 1000 10000 loglog -0.8 -0.4 0 0.4 0.8 0 2 4 6 8 10 bubble
Drawn by running the program above.

The whole program

Runnable as it stands: qu run catalog/qu_plot_types.qu

# Every kind of plot Qu draws, one panel each.

#

# The third sheet in the reference set, after `qu_markers.qu` (every glyph)

# and `qu_line_styles.qu` (every line style). This one answers a different

# question: not "what can a series look like" but "what SHAPE of picture

# can I ask for", which is the thing you want to see all at once when

# choosing how to show a result.

#

# Each panel is the smallest honest example of its type -- real data, real

# axes, no decoration beyond what the type itself needs.

#

# Run:  qu run catalog/qu_plot_types.qu


theme("publication")
figure_size(7.16, 9.0, unit = "in")

x  = linspace(0, 10, 200)
xs = linspace(0, 10, 12)

split plot 5 3

# ---- lines -------------------------------------------------------------

next plot 1
plot(x, sin(x))
title("plot")
grid on

next plot 2
scatter(xs, sin(xs))
title("scatter")
grid on

next plot 3
stem(xs, sin(xs))
title("stem")
grid on

next plot 4
stair(xs, sin(xs))
title("stair / step")
grid on

next plot 5
area(x, sin(x) + 1.5)
title("area")
grid on

next plot 6
fill_between(x, sin(x) - 0.3, sin(x) + 0.3)
plot(x, sin(x))
title("fill_between")
grid on

# ---- categorical --------------------------------------------------------

next plot 7
bar((4, 7, 3, 6))
xticklabels("A", "B", "C", "D")
title("bar")
grid on

# Stacking and grouping are done by CALLING AGAIN, not by passing several

# vectors to one call: each call adds a series to the panel, and the panel

# is what stacks or groups them. `stackbar(a, b)` reads `a` as x and `b` as

# y, exactly like `plot` -- so the one-call form silently draws a single

# series and looks like a plain `bar`.

next plot 8
bin = (1, 2, 3, 4)
stackbar(bin, (4, 7, 3, 6))
stackbar(bin, (2, 1, 4, 2))
xticklabels("A", "B", "C", "D")
title("stackbar")
grid on

next plot 9
groupbar(bin, (4, 7, 3, 6))
groupbar(bin, (2, 1, 4, 2))
xticklabels("A", "B", "C", "D")
title("groupbar")
grid on

# ---- distributions ------------------------------------------------------

next plot 10
hist(randn(2000), bins = 30)
title("hist")
grid on

next plot 11
boxplot(randn(200), randn(200) + 1.5, randn(200) - 1)
title("boxplot")
grid on

next plot 12
errorbar(xs, sin(xs), 0.15 + 0*xs)
title("errorbar")
grid on

# ---- scales and fields ---------------------------------------------------

next plot 13
f = logspace(0, 4, 200)
semilogx(f, 20*log10(1 ./ sqrt(1 + (f/100).^2)))
title("semilogx")
grid on

next plot 14
loglog(f, 1 ./ f)
title("loglog")
grid on

next plot 15
bubble(xs, sin(xs), 4 + 8*abs(sin(xs)))
title("bubble")
grid on

savefig("qu_plot_types.svg")
savefig("qu_plot_types.pdf")
print("wrote qu_plot_types.svg and .pdf")