Skip to content

cjdoris/ShadeYourData.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShadeYourData.jl

ShadeYourData.jl n.

  1. A cheap clone of datashader.org for Julia.
  2. Interactive plotting of millions of data points.

Getting started

Install like so: ] add https://github.com/cjdoris/ShadeYourData.jl.

See the example below, or read the docstring for datashade!.

Example

In this example, we plot all 2.6M UK postcodes from this dataset.

ShadeYourData.jl example

You can watch it in action here. Notice that when zoomed out, the density of points is shown via a colormap, but as we zoom in and the points get separated, we plot them bigger so you can see them individually.

# ShadeYourData works best with MakieLayout
using CSV, DataFrames, Makie, MakieLayout, ShadeYourData

# load the dataset
df = CSV.read("/path/to/postcodes.csv", copycols=true)
dropmissing!(df, [:Easting, :Northing])

# set up a new scene
scene, layout = layoutscene()
ax = layout[1,1] = LAxis(scene)

# `datashade!` is the main plotting routine we provide
ds = datashade!(ax, df.Easting, df.Northing, colormap=:dense)

# post-process the aggregated image by applying an autospread (makes points bigger when they are spread out) and rescaling by `log1p` to lessen the extremal values
ds.post = x -> log1p.(ShadeYourData.autospread(x))

# force the data aspect ratio to be 1
# you can achieve the same with just `ax.autolimitaspect = true`, but currently zooming doesn't work well when you do this
ax.aspect = DataAspect()
xlims!(ax, -300_000, 900_000)
ylims!(ax, -100_000, 1_100_000)

# take a look
display(scene)

About

Interactive plotting of millions of data points

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages