View Source Contex.Gallery.PointPlots (ContEx v0.5.0)
A gallery of Line Charts.
Have one to share?
Do you have an interesting plot you want to share? Something you learned the hard way that should be here, or that's just great to see? Just open a ticket on GitHub and we'll post it here.
Link to this section Summary
Functions
PointPlots using a log scale.
Link to this section Functions
PointPlots using a log scale.
Masked mode
As negative numbers cannot be plotted with logarithms, as a default we just replace them with zeros (maked mode).
Rendering took 24 ms - Size: 35.03 Kb
data =
-200..200
|> Enum.map(fn v -> {v / 10.0, v / 10.0} end)
ds = Dataset.new(data, ["x", "y"])
options = [
mapping: %{x_col: "x", y_cols: ["y"]},
data_labels: true,
orientation: :vertical,
custom_y_scale:
ContinuousLogScale.new(domain: {-20, 20}, negative_numbers: :mask),
colour_palette: ["ff9838", "fdae53", "fbc26f", "fad48e", "fbe5af", "fff5d1"]
]
Plot.new(ds, PointPlot, 500, 400, options)
|> Plot.titles("Masked log scale", "")
|> Plot.axis_labels("x", "y (log)")
Symmetric mode
As negative numbers cannot be plotted with logarithms, we can "make do" and use the symmetric mode.
Rendering took 1 ms - Size: 37.582 Kb
data =
-200..200
|> Enum.map(fn v -> {v / 10.0, v / 10.0} end)
ds = Dataset.new(data, ["x", "y"])
options = [
mapping: %{x_col: "x", y_cols: ["y"]},
data_labels: true,
orientation: :vertical,
custom_y_scale:
ContinuousLogScale.new(domain: {-20, 20}, negative_numbers: :sym),
colour_palette: ["ff9838", "fdae53", "fbc26f", "fad48e", "fbe5af", "fff5d1"]
]
Plot.new(ds, PointPlot, 500, 400, options)
|> Plot.titles("A symmetric log scale", "")
|> Plot.axis_labels("x", "y (log)")
Linear mode
As numbers below zero are negative as logarithms, and may get really big fast, you may want to "linearize" them.
This works in masked mode (as shown) but also in symmetric mode.
Rendering took 1 ms - Size: 35.118 Kb
data =
-200..200
|> Enum.map(fn v -> {v / 10.0, v / 10.0} end)
ds = Dataset.new(data, ["x", "y"])
options = [
mapping: %{x_col: "x", y_cols: ["y"]},
data_labels: true,
orientation: :vertical,
custom_y_scale:
ContinuousLogScale.new(domain: {-20, 20}, negative_numbers: :mask, linear_range: 1),
colour_palette: ["ff9838", "fdae53", "fbc26f", "fad48e", "fbe5af", "fff5d1"]
]
Plot.new(ds, PointPlot, 500, 400, options)
|> Plot.titles("A masked log scale", "With linear range")
|> Plot.axis_labels("x", "y")
Automatic range
You can have the logscale "infer" the domain from data, so you don't have to think twice about it.
Rendering took 1 ms - Size: 35.03 Kb
data =
-200..200
|> Enum.map(fn v -> {v / 10.0, v / 10.0} end)
ds = Dataset.new(data, ["x", "y"])
options = [
mapping: %{x_col: "x", y_cols: ["y"]},
data_labels: true,
orientation: :vertical,
custom_y_scale:
ContinuousLogScale.new(dataset: ds, axis: "y", negative_numbers: :mask),
colour_palette: ["ff9838", "fdae53", "fbc26f", "fad48e", "fbe5af", "fff5d1"]
]
Plot.new(ds, PointPlot, 500, 400, options)
|> Plot.titles("Masked log scale", "")
|> Plot.axis_labels("x", "y (log)")