Skip to main content
Ctrl+K

Plotting in Julia

  • Julia visualization example notebooks
  • PythonPlot.jl gallery
  • Plots.jl gallery
  • Binder logo Binder
  • Colab logo Colab
  • .ipynb

PythonPlot.jl gallery

Contents

  • Annotations
  • Axis placement
  • Bar plot
  • Broken axis subplots
  • Custom Time
  • Error bar
  • Histogram
  • Major and minor ticks
  • Multiple axis
    • Sharing the Legend Box in Twin Axes
  • Pie Chart
  • Quiver plots
  • Scatter Plot
  • Subplots
  • Surface plot
  • Windrose bar and line plots

PythonPlot.jl gallery#

From this awesome gist: https://gist.github.com/gizmaa/7214002

using Random
import PythonPlot as plt
plt.using3D()
Random.seed!(2021)
Random.TaskLocalRNG()

Annotations#

using Dates, LaTeXStrings
import PythonPlot as plt

Data: Generate an hour of data at 10Hz.

Generate time array

x = collect(DateTime(2013,10,4):Dates.Millisecond(100):DateTime(2013,10,4,1))
36001-element Vector{Dates.DateTime}:
 2013-10-04T00:00:00
 2013-10-04T00:00:00.100
 2013-10-04T00:00:00.200
 2013-10-04T00:00:00.300
 2013-10-04T00:00:00.400
 2013-10-04T00:00:00.500
 2013-10-04T00:00:00.600
 2013-10-04T00:00:00.700
 2013-10-04T00:00:00.800
 2013-10-04T00:00:00.900
 ⋮
 2013-10-04T00:59:59.200
 2013-10-04T00:59:59.300
 2013-10-04T00:59:59.400
 2013-10-04T00:59:59.500
 2013-10-04T00:59:59.600
 2013-10-04T00:59:59.700
 2013-10-04T00:59:59.800
 2013-10-04T00:59:59.900
 2013-10-04T01:00:00

Convert time from milliseconds from day 0 to days from day 0

x = Dates.value.(x)/1000/60/60/24
y = sin.(2*pi*collect(0:2*pi/(length(x)+1):2*pi-(2*pi/length(x))))

dx = maximum(x) - minimum(x)
dy = maximum(y) - minimum(y)


y2 = 10rand(21) .- 3

x2 = collect(minimum(x):dx/20:maximum(x))
x3 = collect(minimum(x):dx/20:maximum(x))

y3 = 10rand(21) .- 3

fig, ax = plt.subplots(figsize=(8, 8))
Python: (<Figure size 800x800 with 1 Axes>, <Axes: >)

Plot a basic line

ax.plot_date(x,y, linestyle="-", marker="None", label="Test Plot")
<sys>:0: UserWarning: marker is redundantly defined by the 'marker' keyword argument and the fmt string "o" (-> marker='o'). The keyword argument will take precedence.
Python: [<matplotlib.lines.Line2D object at 0x7ff58c9b4410>]

Fit the axis tightly to the plot

ax.axis("tight")
ax.set_title("U Component of Wind")
ax.grid("on")
ax.legend(loc="upper right",fancybox="true")
Python: <matplotlib.legend.Legend object at 0x7ff58c9570e0>

Text Styling

font1 = Dict("family"=>"serif",
             "color"=>"darkred",
             "weight"=>"normal",
             "size"=>16)
ax.set_xlabel("Time", fontdict=font1)        ## X Axis font formatting
ax.set_ylabel("Velocity (m/s)")
plt.setp(ax.get_yticklabels(),fontsize=24,color="blue") ## Y Axis font formatting
Python: [None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]

Arrow Tests: This arrows orient toward the x-axis, the more horizontal they are the more skewed they look

ax.arrow(x[convert(Int64,floor(length(x)/2))],
        0.4,
        0.0009,
        0.4,
        head_width=0.001,
        width=0.00015,
        head_length=0.07,
        overhang=0.5,
        head_starts_at_zero="true",
        facecolor="red")

ax.arrow(x[convert(Int64,floor(0.3length(x)))]-0.25dx,
        y[convert(Int64,floor(0.3length(y)))]+0.25dy,
        0.25dx,
        -0.25dy,
        head_width=0.001,
        width=0.00015,
        head_length=0.07,
        overhang=0.5,
        head_starts_at_zero="true",
        facecolor="red",
        length_includes_head="true")
Python: <matplotlib.patches.FancyArrow object at 0x7ff58c9e5590>

Text Annotation Tests

ax.annotate("Look, data!",
    xy=[x[convert(Int64,floor(length(x)/4.1))];y[convert(Int64,floor(length(y)/4.1))]],
    xytext=[x[convert(Int64,floor(length(x)/4.1))]+0.1dx;y[convert(Int64,floor(length(y)/4.1))]+0.1dy],
    xycoords="data",
    arrowprops=Dict("facecolor"=>"black")) # Julia dictionary objects are automatically converted to Python object when they pass into a PythonPlot function
ax.annotate("Figure Top Right",
    xy=[1;1],
    xycoords="figure fraction",
    xytext=[0,0],
    textcoords="offset points",
    ha="right",
    va="top")
ax.annotate(L"$\int x = \frac{x^2}{2} + C$",
    xy=[1;0],
    xycoords="axes fraction",
    xytext=[-10,10],
    textcoords="offset points",
    fontsize=30.0,
    ha="right",
    va="bottom")

fig.autofmt_xdate(bottom=0.2,rotation=30,ha="right")

fig
_images/4e19d5caba597a44e1be3524a77ad2fe5652ec700cfe9175c50e50455638dd86.png

Axis placement#

import PythonPlot as plt

Data

x = 0:pi/50:2pi
y = sin.(x)

fig, axs = plt.subplots(2, 1)

ax = axs[0]

ax.plot(x,y)
ax.axis("tight")
ax.spines["top"].set_visible(false) ## Hide the top edge of the axis
ax.spines["right"].set_visible(false) ## Hide the right edge of the axis
ax.spines["left"].set_position("center") ## Move the right axis to the center
ax.spines["bottom"].set_position("center") ## Most the bottom axis to the center
ax.xaxis.set_ticks_position("bottom") ## Set the x-ticks to only the bottom
ax.yaxis.set_ticks_position("left") ## Set the y-ticks to only the left

ax = axs[1]

ax.plot(x,y)
ax.axis("tight")
ax.spines["top"].set_visible(false) ## Hide the top edge of the axis
ax.spines["right"].set_visible(false) ## Hide the right edge of the axis
ax.xaxis.set_ticks_position("bottom")
ax.yaxis.set_ticks_position("left")
ax.spines["left"].set_position(("axes",-0.03)) ## Offset the left scale from the axis
ax.spines["bottom"].set_position(("axes",-0.05)) ## Offset the bottom scale from the axis
ax.set_xlabel("X Axis")
ax.set_ylabel("Y Axis")

fig
_images/eb1e098100b960bcc385c2ff487de5dba6c999b45b82e55df21d9a918ccc9734.png

Bar plot#

import PythonPlot as plt

x = [1:1:50;]
y = 100*rand(50)

fig, axs = plt.subplots(2, 1, figsize=(8,8))

ax = axs[0]

ax.bar(x,y,color="#0f87bf",align="center",alpha=0.4)
ax.axis("tight")
ax.grid("on")
ax.set_title("Vertical Bar Plot")
ax.set_xlabel("X")
ax.set_ylabel("Y")

ax = axs[1]
ax.barh(x,y,color="#0f87bf",align="center",alpha=0.4)
ax.axis("tight")
ax.set_title("Horizontal Bar Plot")
ax.grid("on")
ax.set_xlabel("X")
ax.set_ylabel("Y")

fig.suptitle("Bar Plot Examples")

fig
_images/dc5c648db951d3769678b24dea2cf7acdee8f99330af8fca84e574376a460bfa.png

Broken axis subplots#

using PythonCall
import PythonPlot as plt

axes_grid1 = pyimport("mpl_toolkits.axes_grid1")

x = rand(100)
y = rand(100)
y2 = rand(100).+10

fig, axes = plt.subplots(2, 1, figsize=(8, 8), sharex=true)

ax = axes[0]
divider = axes_grid1.make_axes_locatable(ax)
ax2 = divider.new_vertical(size="100%", pad=0.1)
fig.add_axes(ax2)
Python: <Axes: >

Lower Portion of First Plot

ax.scatter(x, y)
ax.set_ylim(0, 1)
ax.spines["top"].set_visible(false)
Python: None

Upper Portion of First Plot

ax2.scatter(x, y2)
ax2.set_ylim(10, 11)
ax2.tick_params(bottom="off", labelbottom="off")
ax2.spines["bottom"].set_visible(false)

fig
_images/3f68355c7be0466d5d9026e64f4e9c6c75a55f591134be5b222c6a8ff613066f.png

Add Line Break Markings: https://matplotlib.org/examples/pylab_examples/broken_axis.html

Upper Line Break Markings

d = 0.015  # how big to make the diagonal lines in axes coordinates
ax2.plot((-d, +d), (-d, +d), transform=ax2.transAxes, color="k", clip_on=false,linewidth=0.8)        ## Left diagonal
ax2.plot((1 - d, 1 + d), (-d, +d), transform=ax2.transAxes, color="k", clip_on=false,linewidth=0.8)  ## Right diagonal
Python: [<matplotlib.lines.Line2D object at 0x7ff58c1eb250>]

Lower Line Break Markings

ax.plot((-d, +d), (1 - d, 1 + d), transform=ax.transAxes, color="k", clip_on=false,linewidth=0.8)  ## Left diagonal
ax.plot((1 - d, 1 + d), (1 - d, 1 + d), transform=ax.transAxes, color="k", clip_on=false,linewidth=0.8)  ## Right diagonal

axes[1].scatter(x, y)

fig
_images/07b3d1bb073f4cb622d65e06abfc8d9a20c37441af30b86b0ccd383ca0a5cbde.png

Custom Time#

using Dates
using PythonCall
import PythonPlot as plt
matplotlib = pyimport("matplotlib")
Python: <module 'matplotlib' from '/opt/hostedtoolcache/Python/3.13.7/x64/lib/python3.13/site-packages/matplotlib/__init__.py'>

Data

dt = Dates.Hour(1)
time = collect(DateTime(2014,11,20):dt:DateTime(2014,11,22))
y = 10rand(length(time))
dfmt = Dates.DateFormat("yyyy-mm-dd HH:MM:SS")
font1 = Dict("fontname"=>"Sans","style"=>"normal")
Dict{String, String} with 2 entries:
  "fontname" => "Sans"
  "style"    => "normal"

Convert time from milliseconds from day 0 to days from day 0

time2 = Dates.value.(time)/1000/60/60/24

timespan = "\n" * Dates.format(minimum(time),dfmt) * " - " * Dates.format(maximum(time),dfmt)

majorformatter = matplotlib.dates.DateFormatter("%d.%m.%Y")
minorformatter = matplotlib.dates.DateFormatter("%H:%M")
majorlocator = matplotlib.dates.DayLocator(interval=1)
minorlocator = matplotlib.dates.HourLocator(byhour=(8, 16))
Python: <matplotlib.dates.HourLocator object at 0x7ff58ca27770>

Plot

fig, ax = plt.subplots(figsize=(8, 8))
ax.plot_date(time2,y,linestyle="-",marker="None",label="test")
ax.axis("tight")
ax.set_title("Random Data Against Time\n" * timespan)

ax.grid("on")
ax.set_xlabel("Time")
ax.set_ylabel("Stuff",fontdict=font1)

ax.xaxis.set_major_formatter(majorformatter)
ax.xaxis.set_minor_formatter(minorformatter)
ax.xaxis.set_major_locator(majorlocator)
ax.xaxis.set_minor_locator(minorlocator)

fig.autofmt_xdate(bottom=0.2,rotation=30,ha="right")
fig.set_tight_layout(true)
fig
_images/e2fe5f8170291b259edf8c5aeeef276aaa8426339c17d93bfaaf6a6aef01ebe5.png

Error bar#

using Dates
import PythonPlot as plt

x = collect(DateTime(2013,10,4):Dates.Day(1):DateTime(2013,10,9))
y = [0.9;0.75;0.5;0.4;0.35;0.3]

uppererror = [0.05 0.05 0.05 0.03 0.15 0.05;]
lowererror = [0.15 0.2 0.05 0.1 0.05 0.05;]
errs = [lowererror; uppererror]

fig, ax = plt.subplots(figsize=(8, 8))
ax.plot_date(x,y,linestyle="-",label="Base Plot") ## Basic line plot
ax.errorbar(x,y,yerr=errs,fmt="o") ## Plot irregular error bars
ax.axis("tight")

ax.set_title("Error Bar Example")
ax.set_xlabel("Time")
ax.set_ylabel("Some Data")
ax.grid("on")

fig.autofmt_xdate(bottom=0.2,rotation=30,ha="right") ## Autoformat the time format and rotate the labels so they don't overlap
fig
_images/b19285cdffe6bd51cec2cf3956e3568e56f677e09f8c0223210cc653d4acdb9c.png

Histogram#

import PythonPlot as plt

x = randn(1000)
nbins = 50
fig, ax = plt.subplots()

ax.hist(x,nbins)

ax.grid("on")
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_title("Histogram")

fig
_images/6a8eea178a688c2d86faf307a45bd0876fba8a31441fbfbe71d5475aa93ea81c.png

Major and minor ticks#

using PythonCall
import PythonPlot as plt
matplotlib = pyimport("matplotlib")

x = collect(0.0:0.01:100.0)
y = @. sin(0.1pi*x) * exp(-0.01x)

fig, ax = plt.subplots(figsize=(8,8))

ax.plot(x,y)
ax.set_xlabel("X Axis")
ax.set_ylabel("Y Axis")
ax.grid("on")
ax.set_title("Major and Minor Ticks")
Python: Text(0.5, 1.0, 'Major and Minor Ticks')

Set the tick interval

Mx = matplotlib.ticker.MultipleLocator(20) ## Define interval of major ticks
f = matplotlib.ticker.FormatStrFormatter("%1.2f") ## Define format of tick labels
ax.xaxis.set_major_locator(Mx) ## Set interval of major ticks
ax.xaxis.set_major_formatter(f) ## Set format of tick labels

mx = matplotlib.ticker.MultipleLocator(5) ## Define interval of minor ticks
ax.xaxis.set_minor_locator(mx) ## Set interval of minor ticks

My = matplotlib.ticker.MultipleLocator(0.5) ## Define interval of major ticks
ax.yaxis.set_major_locator(My) ## Set interval of major ticks

my = matplotlib.ticker.MultipleLocator(0.1) ## Define interval of minor ticks
ax.yaxis.set_minor_locator(my) ## Set interval of minor ticks

ax.xaxis.set_tick_params(which="major",length=10,width=2,labelsize=16)
ax.xaxis.set_tick_params(which="minor",length=5,width=2)

fig
_images/7df6417e45252896c463c4a8353b68e8384c90ef9628e2cd1b1ded4d019d8503.png

Multiple axis#

import PythonPlot as plt

n = 15
x = collect(1:n)
y1 = 10rand(n,1) .- 2
y2 = 1000rand(n,1)
y3 = 30rand(n,1) .- 15

fig, ax = plt.subplots()

ax.plot(x,y1,linestyle="-",marker="o",label="First")
ax.set_title("Multi-axis Plot")
ax.set_xlabel("X Axis")
font1 = Dict("color"=>"blue")
ax.set_ylabel("Left Axis",fontdict=font1)
plt.setp(ax.get_yticklabels(),color="blue")

new_position = [0.06;0.06;0.77;0.91]
ax.set_position(new_position)
Python: None

Create another axis on top of the current axis

ax2 = ax.twinx()
font2 = Dict("color"=>"purple")
ax2.set_ylabel("Right Axis",fontdict=font2)
ax2.plot(x,y2,color="purple",linestyle="-",marker="o",label="Second")
ax2.set_position(new_position)
plt.setp(ax2.get_yticklabels(),color="purple")
Python: [None, None, None, None, None, None, None, None, None, None]

Create another axis on top of the current axis

ax3 = ax.twinx()
ax3.spines["right"].set_position(("axes",1.12)) ## Offset the y-axis label from the axis itself so it doesn't overlap the second axis
font3 = Dict("color"=>"green")
ax3.set_ylabel("Far Right Axis",fontdict=font3)
ax3.plot(x,y3,color="green",linestyle="-",marker="o",label="Third")
ax3.set_position(new_position)
plt.setp(ax.get_yticklabels(),color="green")

ax.axis("tight")
Python: (np.float64(0.29999999999999993), np.float64(15.7), np.float64(-2.4592934038192786), np.float64(8.444242753056782))

Enable just the right part of the frame

ax3.set_frame_on(true) ## Make the entire frame visible
ax3.patch.set_visible(false) ## Make the patch (background) invisible so it doesn't cover up the other axes' plots
ax3.spines["top"].set_visible(false) ## Hide the top edge of the axis
ax3.spines["bottom"].set_visible(false) ## Hide the bottom edge of the axis

fig
_images/b58f985339e43059947f1eb5168b6abfd626850a0c172dde02312923547f5635.png

Sharing the Legend Box in Twin Axes#

import PythonPlot as plt

x1 = 1:10
fig, ax1 = plt.subplots()
l1 = ax1.plot(x1, x1, "r-")
ax2 = ax1.twinx()
l2 = ax2.plot(x1, exp.(x1), "g-")
ax1.legend([first(l1), first(l2)], ["x", "exp(x)"])
fig
_images/55c4f2d487aece9b044892fa2c4b4cd01476f6f88afa499f9d6ff2cdb3759cc3.png

Pie Chart#

import PythonPlot as plt

labels = ["Lager","Pilsner","Stout","IPA"]
colors = ["yellowgreen","gold","lightskyblue","lightcoral"]

explode = zeros(length(labels))
explode[2] = 0.1 ## Move slice 2 out by 0.1

sizes = [15, 30, 45, 10]

font = Dict("fontname"=>"Sans","weight"=>"semibold")

fig, ax = plt.subplots()
ax.pie(sizes,
        labels=labels,
        shadow=true,
        startangle=90,
        explode=explode,
        colors=colors,
        autopct="%1.1f%%",
        textprops=font)
ax.axis("equal")
ax.set_title("Beer")
fig
_images/e8520403bb91a42106cc8d930a09392dfae044486547cbcc309e80574bf06b52.png

Quiver plots#

import PythonPlot as plt
R = -10:1:9
X = [R;]'
Y = [R;]
U = repeat([R;]',length(X))
V = repeat([R;],1,length(Y))

fig, ax = plt.subplots(figsize=(8,8))
q = ax.quiver(X,Y,U,V)
ax.quiverkey(q,X=0.07,Y = 0.05, U = 10,coordinates="figure", label="Quiver key, length = 10",labelpos = "E")
ax.set_title("Quiver Plot Example")
fig
_images/8347c99bacac31c8aedaa0dc940c27cabd0bde2c1db9fa9bc06f40da81ba7d4d.png

Scatter Plot#

import PythonPlot as plt

x = 100*rand(50)
y = 100*rand(50)
areas = 800*rand(50)

fig, ax = plt.subplots(figsize=(8,8))
ax.scatter(x,y,s=areas,alpha=0.5)
ax.set_title("Scatter Plot")
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.grid("on")
fig
_images/a226cf9c84cf36537e3fee8984c93c982201af3d446ac3e50339441e2d8ace84.png

Subplots#

import PythonPlot as plt

fig = plt.figure("PythonPlot_subplot_mixed",figsize=(8,8)) ## Create a new blank figure
##fig.set_figheight(7) # Does not work
##fig.set_figwidth(3) # Doesn not work
plt.subplot(221) ## Create the 1st axis of a 2x2 arrax of axes
plt.grid("on") ## Create a grid on the axis
plt.title("221") ## Give the most recent axis a title
plt.subplot(222,polar="true") ## Create a plot and make it a polar plot, 2nd axis of 2x2 axis grid
plt.title("222")
ax = plt.subplot(223,polar="true") ## Create a plot and make it a polar plot, 3rd axis of 2x2 axis grid
ax.set_theta_zero_location("N") ## Set 0 degrees to the top of the plot
ax.set_theta_direction(-1) ## Switch the polar plot to clockwise
plt.title("223")
plt.subplot(224) ## Create the 4th axis of a 2x2 arrax of axes
plt.xlabel("This is an X axis")
plt.ylabel("This is a y axis")
plt.title("224")
fig.suptitle("2x2 Subplot")

fig
_images/9a6af689d03ffde73c4365559c2b46bfe1d5595f2873ed7c5456013d8e5f76dc.png

Shared Axis

fig = plt.figure("PythonPlot_subplot_touching",figsize=(8,8))
plt.subplots_adjust(hspace=0.0) ## Set the vertical spacing between axes
plt.subplot(311) ## Create the 1st axis of a 3x1 array of axes
ax1 = plt.gca()
ax1.set_xscale("log") ## Set the x axis to a logarithmic scale
plt.setp(ax1.get_xticklabels(),visible=false) ## Disable x tick labels
plt.grid("on")
plt.title("Title")
plt.yticks(0.1:0.2:0.9) ## Set the y-tick range and step size, 0.1 to 0.9 in increments of 0.2
plt.ylim(0.0,1.0) ## Set the y-limits from 0.0 to 1.0
plt.subplot(312,sharex=ax1) ## Create the 2nd axis of a 3x1 array of axes
ax2 = plt.gca()
ax2.set_xscale("log") ## Set the x axis to a logarithmic scale
plt.setp(ax2.get_xticklabels(),visible=false) ## Disable x tick labels
plt.grid("on")
plt.ylabel("Log Scale")
plt.yticks(0.1:0.2:0.9)
plt.ylim(0.0,1.0)
plt.subplot(313,sharex=ax2) ## Create the 3rd axis of a 3x1 array of axes
ax3 = plt.gca()
ax3.set_xscale("log") ## Set the x axis to a logarithmic scale
plt.grid("on")
plt.xlabel("Log Scale")
plt.yticks(0.1:0.2:0.9)
plt.ylim(0.0,1.0)
plt.suptitle("3x1 Shared Axis")

fig
_images/1972dfaa4057201e70fd5eee8ee2d38ed4142c3b6db166229b217b9c8d8027af.png

Surface plot#

using Distributions
using LinearAlgebra
import PythonPlot as plt
plt.using3D() ## Needed to create a 3D subplot

n = 100
x = range(-3,stop=3,length=n)
y = range(-3,stop=3,length=n)

xgrid = repeat(x',n,1)
ygrid = repeat(y,1,n)

z = zeros(n,n)

for i in 1:n
    for j in 1:n
        z[i:i,j:j] .= pdf(MvNormal(Matrix(1.0I,2,2)),[x[i];y[j]])
    end
end

fig = plt.figure("PythonPlot_surfaceplot",figsize=(8,8))

ax = fig.add_subplot(2,1,1,projection="3d")
ax.plot_surface(xgrid, ygrid, z, rstride=2,edgecolors="k", cstride=2, cmap=plt.ColorMap("gray"), alpha=0.8, linewidth=0.25)
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_title("Surface Plot")

ax = fig.add_subplot(2,1,2)
cp = ax.contour(xgrid, ygrid, z, colors="black", linewidth=2.0)
ax.clabel(cp, inline=1, fontsize=10)
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_title("Contour Plot")
fig.tight_layout()

fig
<sys>:0: UserWarning: The following kwargs were not used by contour: 'linewidth'
_images/9d8f363a45ca058eabcb99c2a5369a20b11ded89dfc4641537b3900e0543d2db.png

Windrose bar and line plots#

import PythonPlot as plt
theta = collect(0:2pi/30:2pi)
r = rand(length(theta))
width = 2pi/length(theta)
0.2026833970057931

Windrose Line Plot

fig = plt.figure(figsize=(8,8)) ## Create a new figure
ax = plt.axes(polar="true") ## Create a polar axis

ax.set_title("Wind Rose - Line")
ax.plot(theta,r,linestyle="-",marker="None") ## Basic line plot

dtheta = 10

ax.set_thetagrids(collect(0:dtheta:360-dtheta)) ## Show grid lines from 0 to 360 in increments of dtheta
ax.set_theta_zero_location("N") ## Set 0 degrees to the top of the plot
ax.set_theta_direction(-1) ## Switch to clockwise

fig
_images/8ead1c1586831a01b8632cc13c68957d9062634a669c96f4819b13750536e54c.png
fig = plt.figure("PythonPlot_windrose_barplot",figsize=(8,8)) ## Create a new figure
ax = plt.axes(polar="true") ## Create a polar axis
ax.set_title("Wind Rose - Bar")
ax.bar(theta,r,width=width) ## Bar plot

dtheta = 10
ax.set_thetagrids(collect(0:dtheta:360-dtheta)) ## Show grid lines from 0 to 360 in increments of dtheta
ax.set_theta_zero_location("N") ## Set 0 degrees to the top of the plot
ax.set_theta_direction(-1) ## Switch to clockwise

fig
_images/aa7f22942b3378a2cdc936242e6ffceb25ab703ef984adc22fa6ebc2cc4721d1.png

This notebook was generated using Literate.jl.

previous

Julia visualization example notebooks

next

Plots.jl gallery

Contents
  • Annotations
  • Axis placement
  • Bar plot
  • Broken axis subplots
  • Custom Time
  • Error bar
  • Histogram
  • Major and minor ticks
  • Multiple axis
    • Sharing the Legend Box in Twin Axes
  • Pie Chart
  • Quiver plots
  • Scatter Plot
  • Subplots
  • Surface plot
  • Windrose bar and line plots

By Wen-Wei Tseng

© Copyright 2022.