Plotting Simple Functions

This website is reader-supported. I may earn an affiliate commission at no cost to you if you purchase using the links below. (more info)

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 y=x^2 with a domain of x=-10 to x=10. Each plot includes a grid, labeled x and y-axis, and title. The domain is computed with interval of 0.01 on all.


grid on
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')


using Plots
x=-10:0.01:10; y=x.^2;
    xlabel = "x",
    ylabel = "y",
    title = "Simple Plot y=x^2"

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.

Get my 2023 Alaska Wall Calendar or Aurora Calendar here!  

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.

You can help support me and this website!

Support on Patreon
Subscribe to Newsletter

Add a comment

*Please complete all fields correctly

Related Posts

Fata Morgana – Superior Mirage
Parhelion – Sun Dog