JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

spork/charts/plot-line-graph

spork


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

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

    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
    * :width - (if no canvas provided) - make a new canvas with the 
      given width in pixels
    * :height - (if no canvas provided) - make a new canvas with the 
      given height in pixels
    * :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-style - How to draw lines. Can be one of :stroke, :plot, 
      :none, :bar, :area, or :stipple. Default is :plot.
    * :line-style-per-column - Optional dictionary to override line 
      style by y-column name.
    * :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.
    * :transpose - When transpose is enabled, draw bar and area charts 
      from the y-axis instead of the x-axis (make horizontal bar 
      charts). Should be used with a transposed axes.

    Returns the modified canvas image.


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 :temperature-2]))

# then you can look at bla.png
veqqqPlayground