GR is available on PyPI and we recommend installing it with pip:
pip install gr
This will automatically install both the GR runtime and the Python wrapper. You may need to install some additional dependencies on Linux:
apt install libxt6 libxrender1 libxext6 libgl1-mesa-glx libqt6widgets6
apt install libxt6 libxrender1 libxext6 libglx-mesa0 libqt6widgets6
yum install libXt libXrender libXext mesa-libGL qt6-qtbase-gui
zypper install libXt6 libXrender1 libXext6 Mesa-libGL1 libQt6Widgets6
pacman -S mesa qt6-base
Note: Depending on the Linux flavor you are using, the package names may differ from the ones mentioned here. This particularly applies to the Qt versions used.
pkg install libXt libXrender libXext mesa-libs qt6
For information on building the GR runtime yourself, see Building the GR Runtime.
GR does not rely on X11 for its non-interactive output formats, so you will not need the dependencies listed above on a headless system.
GR3 uses GLX for OpenGL context creation, which requires a connection to an X server. If you are using a headless sytem, e.g. a Docker container, you can use Xvfb or similar tools to start an X server that can be used by GR3, although it may only provide software rendering.
After installing GR, you can try it out by creating a simple plot:
from gr.pygr import mlab
mlab.plot(range(100), lambda x: x**2)
You can find several tutorials on using GR in the Tutorials section.
You can find a collection of Python scripts using GR in the Examples section.
The Python API for GR consists of:
setlinetype()setlinewidth()setlinecolorind()setmarkertype()inqmarkertype()setmarkersize()inqmarkersize()setmarkercolorind()inqmarkercolorind()settextfontprec()setcharexpan()settextcolorind()setcharheight()setcharup()settextpath()settextalign()setfillintstyle()setfillstyle()setfillcolorind()setcolorrep()setcolormap()setcolormapfromrgb()setarrowstyle()setshadow()settransparency()setresamplemethod()inqresamplemethod()setbordercolorind()inqbordercolorind()setborderwidth()inqborderwidth()setscale()inqscale()setwindow()inqwindow()setviewport()selntran()setclip()setwswindow()setwsviewport()setspace()inqspace()setcoordxform()setprojectiontype()inqprojectiontype()setperspectiveprojection()inqperspectiveprojection()setorthographicprojection()inqorthographicprojection()settransformationparameters()inqtransformationparameters()camerainteraction()setwindow3d()inqwindow3d()setscalefactors3d()inqscalefactors3d()CoordConverter
Coords2D
Coords2DList
Coords3D
Coords3DList
DeviceCoordConverter
ErrorBar
GridCoords3DPlotPlot.addAxes()Plot.addROI()Plot.autoscalePlot.drawGR()Plot.getAxes()Plot.getROI()Plot.isLegendEnabled()Plot.logXinDomain()Plot.logYinDomain()Plot.offsetXLabelPlot.offsetYLabelPlot.pan()Plot.pick()Plot.reset()Plot.select()Plot.setGrid()Plot.setLegend()Plot.setLegendWidth()Plot.setLogX()Plot.setLogY()Plot.sizexPlot.sizeyPlot.subTitlePlot.titlePlot.viewportPlot.xlabelPlot.ylabelPlot.zoom()PlotAxesPlotAxes.COORDLIST_CLASSPlotAxes.COUNTPlotAxes.OPTIONPlotAxes.SCALE_XPlotAxes.SCALE_YPlotAxes.addCurves()PlotAxes.autoscalePlotAxes.backgroundColorPlotAxes.curveDataChanged()PlotAxes.curveVisibilityChanged()PlotAxes.doAutoScale()PlotAxes.drawGR()PlotAxes.getBoundingBox()PlotAxes.getCurves()PlotAxes.getId()PlotAxes.getVisibleCurves()PlotAxes.getWindow()PlotAxes.isGridEnabled()PlotAxes.isReset()PlotAxes.isXDrawingEnabled()PlotAxes.isXLogDomain()PlotAxes.isYDrawingEnabled()PlotAxes.isYLogDomain()PlotAxes.majorxPlotAxes.majoryPlotAxes.plot()PlotAxes.reset()PlotAxes.scalePlotAxes.scaleWindow()PlotAxes.setGrid()PlotAxes.setLogX()PlotAxes.setLogY()PlotAxes.setWindow()PlotAxes.setXDrawing()PlotAxes.setXtickCallback()PlotAxes.setYDrawing()PlotAxes.setYtickCallback()PlotAxes.ticksizePlotAxes.xtickPlotAxes.ytickPlotContour
PlotCurve
PlotSurface
Point
RegionOfInterest
Text
delay()isinstanceof()islistof()ndctowc()readfile()wctondc()