These are chat archives for sandialabs/toyplot

23rd
May 2017
Hannes
@kannes
May 23 2017 12:07
hey, how would i use log scale for x and y in the multiple lines example of https://toyplot.readthedocs.io/en/stable/tutorial.html#plotting ?
at https://toyplot.readthedocs.io/en/stable/tutorial.html#axes it is only done on one toyplot object while here i have axes
ah, i can set them on the canvas object, so in the axes = line
cant say i understand the logic of that though D:
Timothy M. Shead
@tshead2
May 23 2017 17:50
@kannes - Toyplot makes an explicit distinction between a canvas (the 2D space you have set aside for plotting), a coordinate system (that maps data to coordinates within the canvas), and a mark (which specifies a visual representation for your data). Keeping these separate means you can mix-and-match multiple coordinate systems and marks on one canvas in any way that suits you.
A log scale is a property of the coordinate system, so that’s where you set it. In code we usually call the coordinate system “axes” because “coordinate_system” is needlessly verbose. So:
canvas = toyplot.Canvas(width=600, height=300)
axes = canvas.cartesian(xscale=“log”, yscale=“log”)
mark1 = axes.plot(x, y1)
mark2 = axes.plot(x, y2)
mark3 = axes.plot(x, y3)
Or, there’s a more verbose option:
Timothy M. Shead
@tshead2
May 23 2017 17:56
canvas = toyplot.Canvas(width=600, height=300)
axes = canvas.cartesian()
axes.x.scale = "log"
axes.y.scale = "log"
mark1 = axes.plot(x, y1)
mark2 = axes.plot(x, y2)
mark3 = axes.plot(x, y3)
See https://toyplot.readthedocs.io/en/stable/log-scales.html for more examples of coordinate system scales. See https://toyplot.readthedocs.io/en/stable/canvas-layout.html and https://toyplot.readthedocs.io/en/stable/convenience-api.html for additional background on the relationship among canvas, axes, and marks.