-
-
Notifications
You must be signed in to change notification settings - Fork 7
Plot attributes
- Currently the plot attributes are provided as a keyword argument.
- This page is besed on GRUtils.jl.
We will add keyword arguments to two simple graphs: one is a simple 2D line plot and the other is a 3D wireframe. Here, we use Rdatasets Gem to load the data.
require 'gr/plot'
require 'rdatasets'
passenger = RDatasets.load(:datasets, :AirPassengers)
time = passenger["time"]
value = passenger["value"]
GR.plot(time, value)
volcano = RDatasets.datasets.volcano.to_matrix.to_a.transpose
volcano = Numo::DFloat.cast(volcano)
GR.wireframe(volcano)
Set the plot title as the string.
GR.plot(time, value, title: 'Air Passenger numbers from 1949 to 1961')```
GR.plot(time, value, figsize: [1, 1])
GR.plot(time, value, figsize: [6, 2])
Set the approximate size of the window on the screen to be displayed in pixel size. The default size is [600, 450].
GR.plot(time, value, size: [480, 360])
Set the X, Y or Z axis labels as the string.
GR.plot(time, value,
title: 'Air Passenger numbers from 1949 to 1961',
xlabel: 'Date',
ylabel: "Passenger numbers (1000's)")
GR.wireframe(volcano, title: "Maunga Whau (Mt Eden)",
xlabel: "X", ylabel: "Y", zlabel: "Z")
Draw or disable the grid of the current plot axes.
GR.plot(time, value, grid: false)
GR.wireframe(volcano, grid: false)
Set the minor intervals of the ticks for the X, Y or Z axis, and (optionally) the number of minor ticks between major ticks.
GR.plot(time, value, xticks:[0.5, 4], yticks: [50, 2])
GR.wireframe(volcano, xlabel: "X", ylabel: "Y", zlabel: "Z",
xticks: 11, yticks: 13, zticks: 17)
- Under development
Set the limits for the plot axes.
GR.plot(time, value, ylim: [0, 4000], xlim: [1920, 2020])
GR.wireframe(volcano, zlim: [80, 120])
GR.wireframe(volcano.clip(80,120), zlim: [80, 120])
Pan/zoom the axes of the current plot.
Set the viewpoint of three-dimensional plots.
Rotate the viewpoint of the current plot by angle degrees around the vertical axis of the scene, with respect to its current position.
30.times do |i|
GR.wireframe(volcano, rotation: i * 3)
end
Tilt (elevate) the viewpoint of the current plot by angle degrees over the horizontal plane, with respect to its current position.
30.times { |i| GR.wireframe(volcano, tilt: i * 3) }
30.times { |i| GR.wireframe(volcano, tilt: 90 - i * 3) }
Not implemented: movefocus
, turncamera
Reverse the direction of the X-axis, Y-axis or Z-axis, or set them back to their normal direction.
GR.plot time, value, GR.subplot(2,2,1, xflip: false, yflip: false, label: "default", location: 2)
GR.plot time, value, GR.subplot(2,2,2, xflip: true, yflip: false, label: "x flipped", location: 1)
GR.plot time, value, GR.subplot(2,2,3, xflip: false, yflip: true , label: "y fipped", location: 3)
GR.plot time, value, GR.subplot(2,2,4, xflip: true, yflip: true , label: "x,y fipped", location: 4)
GR.wireframe volcano, GR.subplot(2,2,1, xflip: false, yflip: false)
GR.wireframe volcano, GR.subplot(2,2,2, xflip: true, yflip: false)
GR.wireframe volcano, GR.subplot(2,2,3, xflip: false, yflip: true )
GR.wireframe volcano, GR.subplot(2,2,4, xflip: true, yflip: true )
Set the X-axis, Y-axis or Z-axis to be drawn in logarithmic scale, or in linear scale.
GR.plot time, value, GR.subplot(2,1,1, ylabel: "Y")
GR.plot time, value, GR.subplot(2,1,2, ylabel: "ylog", ylog: true)
Not implemented: radians
Set the legend of the plot, using a series of labels.
- 0 "none"
- 1 "upper right"
- 2 "upper left"
- 3 "lower left"
- 4 "lower right"
- 5 "right"
- 6 "center left"
- 7 "center right"
- 8 "lower center"
- 9 "upper center"
- 10 "center"
- 11 "outer upper right"
- 12 "outer center right"
- 13 "outer lower right"
In GRUtils legend
Not implemented: geometrykinds
, colorbar
Add a custom background color to the current figure.
Set or retrieve the values of the current colormap.
User's Guide
Simple, matlab-style API
- Plotting functions
- Plot attributes
- Multiple plots
- Multiple subplots
- Save Plot to a file
- Jupyter Notebook
GR Native functions
For developers