-
-
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)
GR.wireframe volcano xlog: true
GR.wireframe volcano ylog: true
GR.wireframe volcano xlog: true, ylog: true
GR.wireframe volcano -100, zlog: true
complete nonsense.
Not implemented: radians
Set the legend of the plot, using a series of labels.
In GRUtils legend
Not implemented: geometrykinds
, colorbar
Add a custom background color to the current figure.
GR.plot(time, value, "wp", backgroundcolor: 1)
Set or retrieve the values of the current colormap.
The following examples are useful for checking the colormap in your environment.
GR.contourf(volcano, colormap: 40)
GR.contourf(volcano, colormap: 1)
GR::Plot::FONT
Name | |
---|---|
Times_Roman | 101 |
Times_Italic | 102 |
Times_Bold | 103 |
Times_BoldItalic | 104 |
Helvetica_Regular | 105 |
Helvetica_Oblique | 106 |
Helvetica_Bold | 107 |
Helvetica_BoldOblique | 108 |
Courier_Regular | 109 |
Courier_Oblique | 110 |
Courier_Bold | 111 |
Courier_BoldOblique | 112 |
Symbol | 113 |
Bookman_Light | 114 |
Bookman_LightItalic | 115 |
Bookman_Demi | 116 |
Bookman_DemiItalic | 117 |
NewCenturySchlbk_Roman | 118 |
NewCenturySchlbk_Italic | 119 |
NewCenturySchlbk_Bold | 120 |
NewCenturySchlbk_BoldItalic | 121 |
AvantGarde_Book | 122 |
AvantGarde_BookOblique | 123 |
AvantGarde_Demi | 124 |
AvantGarde_DemiOblique | 125 |
Palatino_Roman | 126 |
Palatino_Italic | 127 |
Palatino_Bold | 128 |
Palatino_BoldItalic | 129 |
ZapfChancery_MediumItalic | 130 |
ZapfDingbats | 131 |
CMUSerif-Math | 232 |
DejaVuSans | 233 |
PingFangSC | 234 |
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