I earn commissions if you shop through the affiliate links on this page.
The following are a few examples of how to create a simple plot in Matlab/Octave, Python3, and Julia. I made a similar look between all three programs, trying to keep each as close to the defaults as possible, although all 3 are highly customizable. GNU Octave and Julia are both freely available, and Python interpreters are available for most operating systems. Matlab does cost money, but is nearly identical to GNU Octave (although Matlab has toolboxes and a nicer GUI).
The plot is simply the function with a domain of to . Each plot includes a grid, labeled x and y-axis, and title. The domain is computed with interval of 0.01 on all.
x=-10:0.01:10; y=x.^2; plot(x,y) grid on xlabel('x') ylabel('y') title('Simple Plot y=x^2') print simple_plot.png
import numpy as np import matplotlib import matplotlib.pyplot as plt x = np.arange(-10.0, 10, 0.01) y = x**2 fig, ax = plt.subplots() ax.plot(x, y) ax.set(xlabel='x', ylabel='y', title='Simple Plot y=x^2') ax.grid() fig.savefig("simple_plot.png") plt.show()
using Plots x=-10:0.01:10; y=x.^2; plot(x,y, xlabel = "x", ylabel = "y", title = "Simple Plot y=x^2" ) savefig("simpleplot.png")
Best tool for the job
It’s been a few years since I’ve done any programming at all, besides writing a few simple bash scripts. When I began looking out to see if there’s anything new to the table, I noticed that the Julia language has been rising in popularity. That’s why I’ve decided to include it here, I’m learning it as I brush up on the other two side-by-side.
I have quite an extensive background working with Matlab/Octave for both school and research. A lot of students in science or engineering are probably somewhat familiar with Matlab. It’s a good place to start since Matlab/Octave can both be used with an intuitive GUI which is helpful if you don’t have a strong programming/command line background.
While I’ve spent a bit of time programming with Python, I am far from proficient. Python took the most line of code to make a simple plot. Yet, I really like the matplotlib look out of the box.
After a few days of working with each, I can confidently say that I haven’t lost much when it comes to Octave, and Python is pretty intuitive. I’m still deciding how far I want to go with Julia (I felt weird writing that sentence). Setting it up on my Linux system has not been straight-forward. Getting it to run has been a pain. Although I like the language so far, it feels clean and straightforward. The default plot scheme also looks nice.