Gnuplot Macos

  

Real-time plots in 20 lines

Gnuplot
Article from Issue 244/2021

Some excellent charting and plotting packages can be found, but if you're like me, you sometimes just want to do a quick dynamic test plot without a lot of custom setup. Gnuplot is a command-line charting utility that has been around for a while, and I was amazed how easy it was to get up and running. In only 20 lines of scripting code, I was able to create real-time line and bar charts.

In this article, I introduce Gnuplot with two dynamic examples: The first shows the status of Raspberry Pi I/O pins, and the second is a line chart of CPU diagnostics.

Getting Started

Gnuplot [1] can be installed on Linux, Windows, and macOS. To install Gnuplot on Ubuntu, enter:

Gnuplot is typically run as a command-line utility, but it can also be run manually, with the charting instructions and data values inserted inline. To plot four sets of data points in a line chart, you could enter:

Data block names must begin with a $ character, which distinguishes them from other types of persistent variables. The end-of-data delimiter (EOD here) can be any sequence of characters. For this example, the plot command creates a line chart from the $Mydata variable (Figure 1).

  • It is a directory actually, not a.gnuplot config file. Let’s see what this directory contains ( with the ls command). It has only the start-up file for this version of Gnuplot 5.4.2. We can add a configuration gnuplot file to this directory by using the built-in nano text editor in the terminal. Nano gnuplot Notice, typing nano.gnuplot was.
  • Install gnuplot on Mac OSX. July 25, 2021 Mac App Store. Install gplcver on Mac OSX. Leave a Reply Cancel reply. Your email address will not be.
  • Update, 9 August 2017 Since this article was written about two years ago a new version of gnuplot has been released, as have two new versions of macOS. A couple of my views have also changed as a result of this: I think AquaTerm is good enough for gnuplot and the decision to use X11 should only be a matter of specific needs or taste.

This is an issue for mac os, which is indicated in the INSTALL file of gnuplot. In this file, it mentions two ways to install the ReadLine lib, one is to override the mac os one, while another is install it in your personal space and specify the path to gnuplot installation.

Static Bar Chart

For a simple Gnuplot bar chart, you could plot the real-time status of Raspberry Pi general purpose input/output (GPIO) pins. A static bar chart presentation can be created with a data file (called gpio.dat here):

To plot a bar chart (Figure 2), the fill style and bar width need to be defined. The using 1:3:xtic(2) argument, shown in the next code block, configures the first column in the data file as the x position, the third column as the y value, and the second column as the x-axis labels. Use the interactive commands

to plot the file.

Figure 2: A simple bar chart of Raspberry Pi GPIO pins.

Real-Time Bar Chart

The previous example used a manually created gpio.dat data file. The current status of GPIO pins can be found with the gpio command-line utility [2]. For example, to get the status of GPIO pin 9, enter:

By adding some Bash and an Awk script, you can create a gpio.dat file:

Gnuplot Mac X11

Gnuplot

To make a dynamic bar chart, create the gpio_bars.txt Gnuplot script shown in Listing 1. The Gnuplot scripting language is quite powerful and supports a wide range of functions and control statements.

Gnuplot Macos

Dynamic Bar Chart

Rather than manually adding lines for each GPIO pin status, a for loop can iterate from pins 2 to 29 (lines 14-17). A system command runs the GPIO utility and Bash commands (line 16). To refresh the data, use the replot and pause commands (lines 18 and 19), and enter

Gnuplot Macos Terminal

to run the script (Figure 3).

Figure 3: Dynamic status of Rasp Pi GPIO pins.

12Next »

Buy this article as PDF

Buy Linux Magazine

UK / Australia

Related content

  • Open Data

    A lot of COVID-19 data is available through online REST APIs. With a little ingenuity and some open source tools, you can extract and analyze the data yourself.

  • Workspace: ExifTool

    Understanding the full power of ExifTool can be daunting. We show how to put it to practical use.

  • Go on the Rasp Pi

    We show you how to create a Go web app that controls Raspberry Pi I/O.

  • ACPI Tools

    Linux offers some useful command-line tools that leverage the ACPI power management framework to display detailed data on the status of a laptop battery.

  • Tutorials – Shell Math

    While Bash is not the most advanced environment for doing and visualizing math, its power will surprise you. Learn how to calculate and display your results with shell scripts.

Please enable JavaScript to view the comments powered by Disqus.comments powered by Disqus