2D plotting, drawing, and GUIs using Qwt and Qt
7 Stars
Updated Last
4 Years Ago
Started In
May 2015


Author: Thomas Breloff (@tbreloff)

NOTE: I recommend using Plots.jl as the plotting interface for Qwt.

Plotting using PyQt/PyQwt and a clean interface for 2D scenes using QCanvas. Add to PyQt GUIs and compose many widgets together for complex visualizations.


  • Install python and PyQt4
  • Install PyQwt. If you can't find a bundled package through brew, yum, apt-get, etc:

Tip: On OS X, brew install pyqt and brew install pyqwt might be all you need.


  • Click and drag with the left mouse button to select a rectangle to zoom into
  • To undo 1 zoom, hold ALT and click the right mouse button
  • To redo 1 zoom, hold SHIFT and click the right mouse button
  • To reset the zoom stack, click the middle mouse button


  • Click and drag with the right mouse button


  • Click on legend labels to hide/show individual series


using Qwt

# simple 2D line plot

# these are equivalent
x = randn(100) * 5
y = sin(x)
plot(x, y, linetype=:dots)
scatter(x, y)

# create a heatmap (and optionally fine-tune coloring)
# heatmap_n is the number of bins on each axis
# heatmap_c is the cutoff points of the color range
heatmap(randn(10000), randn(10000); heatmap_n = 20, heatmap_c = (0.05, 0.3))

# pass in vectors or matrices, and it should slice it up properly
Y = rand(100,9)  												# matrix with series in columns
subplot(Y) 															# creates a 3x3 grid of subplots, (one per column)
subplot(rand(100), Y, linetype=:dots)		# same, but has shared x-data
plot(Y)																	# plots 5 lines on the same axis (one per column)

# use both axes
plot(Y[:,1:2], axiss=[:left, :right], colors=[:blue, :green])

# you could also add it after the fact
y1, y2 = Y[:,1], Y[:,2]
plt = plot(y1, color = :blue)
oplot(plt, y2, axis = :right, color = :green)

# there are lots of things to adjust
plot(y1, axis = :right,
				 color = :red,
				 label = "my line",
				 width = 5,
				 linetype = :step,
				 linestyle = :dashdot,
				 marker = :ellipse,
				 markercolor = :cyan,
				 markersize = 20,
				 title = "my title",
				 xlabel = "my x label",
				 ylabel = "my y label"
				 yrightlabel = "my right axis y label",
				 reg = true  # adds a regression line for each series

# and anything can be pluralized by adding an "s" to the end and passing a vector
plot(Y[:,1:2], colors = [:red, :blue])

# add to a plot in real time
plt = plot([0],[0])
for x in 0:0.1:100
	push!(plt, 1, x, sin(x))

# save a png
savepng(plt, "/tmp/png/plot0001.png")

# save an animated gif (requires ffmpeg... saves to $dir/out.gif)
a = animation(plt, "/tmp/png")
for x in 0:0.1:5
	push!(plt, 1, x, sin(x))