2025-02-01
Plots.jl is a data visualisation and plotting library similar to Matplotlib. It provides an interface for several backends, offering great flexibility while remaining simple to use.
Installation:
We also need LaTeXStrings.jl:
Example Plot of the trigonometric functions:
We can use LaTeXStrings to add LaTeX labels to each plot;
Let’s customize the plot by using a different colors, and also add a title and xlabel:
Scatter Plots:
Histograms can be useful for visualizing statistical data:
Surface Plots of the Rosenbrock function:
# Use Plotly backend with MathJax support
plotlyjs()
#plotlyjs(extra_plot_kwargs=KW(:include_mathjax=>"cdn"))
# Rosenbrock function:
f(x, y) = (1 - x)^2 + 100 * (y - x^2)^2
x = range(-2, 2, length=100)
y = range(-1, 3, length=100)
surface(x, y, f, color=:viridis, extra_plot_kwargs=KW(:width=>900, :height=>600))
#surface(x, y, f, color=:viridis)
title!("Rosenbrock function")
xlabel!("x")
ylabel!("y")Contour Plots of the Himmelblau function:
Using the StatsPlots extension, you can use DataFrames as arguments:
Unlike in Seaborn, it is not possible to label the axes automatically.