JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

spork/charts/plot-line-graph

spork


    function
    /usr/local/lib/janet/spork/charts.janet on line 470, column 1

    
    (plot-line-graph &named canvas data to-pixel-space line-style x-column y-column circle-points point-radius x-colors bar-padding stroke-thickness super-sample color-map)

    Plot a line graph or scatter graph on a canvas. This function does 
    not add a set of axis, title, or chart legend, it will only plot 
    the graph lines and points from data.

    * :canvas - a gfx2d/Image to draw on
    * :to-pixel-space - optional function (f x y) -> [pixel-x pixel-y]. 
      Used to convert the metric space to pixel space when plotting 
      points.
    * :data - a data frame to use for x and y data
    * :x-column - the name of the data frame column to use for the x 
      axis
    * :y-column - a single column name or list of column names to use 
      for the y coordinates and connected lines
    * :color-map - a dictionary mapping columns to colors. By default 
      will hash column name to pseudo-random colors
    * :line-type - how to actually draw lines. Can be one of :stroke, 
      :plot, :none, :bar, or :stipple. Default is :plot.
    * :circle-points - add circles around each point
    * :point-radius - how large to make the circles around each point 
      in pixels
    * :super-sample - use super sampling to draw a larger image and 
      then scale it down for anti-aliasing.
    * :bar-padding - space between bars in bar-charts
    * :stroke-thickness - thickness in pixels of the stroke of the 
      graph when :line-type = :stroke
    * :x-colors - for bar and scatter plots, optionally set 
      per-point/per-bar colors with an function (f x y index) called on 
      each point.


1 exampleSign in to add an example
Loading...
(import spork/charts :as c)
(import spork/gfx2d :as g)
(g/save "bla.png" (c/plot-line-graph
                   :canvas (g/blank 100 100)
                   :data {:timestamp [1 2 3 40 5 60]
                          :temperature-1 [75.1 75.2 75.4 75.5 75.5 75.4]
                          :temperature-2 [55.1 55.4 55.7 60.0 60.4 60.9]}
                   :x-column :timestamp
                   :y-column :temperature-1))

# then you can look at bla.png
veqqqPlayground