vplot 1.0
vplot is a wrapper for GNU Plot (gnuplot_i). The source of
gnuplot_i
Dependecies
First, you need to install the
gnuplot
Get started
Import
vplot
import vplot
Declare a new Plot object:
mut p1 := vplot.new()
Set a style and plot a slope of this function
y=ax+b
a = 2
b = 0
y=2x
x
2x
p1.style(vplot.style_linespoints)
p1.label_x(`x`)
p1.label_y(`y`)
p1.plot_slope(2.0)
Whenever you start a new plot session, you should closed it once you are done with it. But, in this simple example, you would not be able to see the output. To be able to see the output, we are going to call
os.input()
os.input('Press any key ...')
p1.close()
Change log:
- Removed all examples and moved to vplot-playground
- Adding support for multiplots (similar to subplots in GNU Octave). Check example multiplot.v
Documentation
Function | Description |
---|---|
vplot.new_plot |
Creates and returns new
Plot
|
vplot.Plot.close() |
Closes the plot sessions and kills corresponding PID. |
vplot.Plot.command(command string) |
Executes a
GNU Plot
|
vplot.Plot.commands(commands []string) |
Executes an array od
GNU Plot
|
vplot.Plot.style(style string) |
Sets the plot style. Check
Plot styles
|
vplot.Plot.label_x(label string) |
Sets the label of X axis. |
vplot.Plot.label_y(label string) |
Sets the label of Y axis. |
vplot.Plot.reset() |
New plot erases the previous plot(s). |
vplot.Plot.plot(d[]f64, string)? |
Plots an array of
f64
|
vplot.Plot.plot2(x []f64, y []f64, title string) |
Plots a pair of data from two arrays of
[]f64
|
vplot.Plot.plot_slope(a f64, b f64, title string) |
Plots a slop function
y = a*x + b
a
b
|
vplot.Plot.plot_equation(equation string, title string) |
As per
gnuplot_i
|
vplot.write_x_csv(filename string, d []f64, title string) |
Writes a CSV file of a given array of
f64
|
Plot styles
-
vplot.style_lines
-
vplot.style_points
-
vplot.style_linespoints
-
vplot.style_impulses
-
vplot.style_dots
-
vplot.style_steps
-
vplot.style_errorbars
-
vplot.style_boxes
-
vplot.style_boxeserrorbars
Tested functions
-
new
-
Plot.close()
-
Plot.style(string)
-
Plot.plot_slope(f64, f64, string)
-
Plot.plot_equation(string, string)
-
Plot.reset()
-
Plot.enable_multiplot(Multiplotter)
-
Plot.disable_multiplot()
-
Plot.command(string)
-
Plot.commands([]string)
-
Plot.plot2d([]f64, []f64, string)
-
Plot.plot([]f64, string)
-
Plot.label_x(string)
-
Plot.label_y(string)
-
vplot.write_x_csv(string, []f64, string)
-
vplot.write_xy_csv(string, []f64, []f64, string)
-
vplot.write_csv(string, []f64, []f64, string)
-
vplot.PlotSession{}
-
vplot.plotter(PlotSession)