Warm tip: This article is reproduced from serverfault.com, please click

How to plot data points with small pieces of png images in julia or in makie.jl?

发布于 2020-11-30 14:24:10

I want to plot data, for example y=x^2+3x-4, using any library in julia like Makie.jl.

The problem is that all data point must be a small image loaded from a png file.

Please assume I know how to plot data using makie.jl with dots, like the following sample borrowed from a page of makie.jl.

I think the dots on the sample are drawn as vector graphics. I just want replace the dots with small images load from a png file. ( And if possible, I want that different dots represent different areas of the original png image. )

In addition, I want to put each small image at a precise coordinate with a precise size.

enter image description here

using GLMakie
using AbstractPlotting
AbstractPlotting.inline!(true)

scene = Scene()

points = [Point2f0(cos(t), sin(t)) for t in LinRange(0, 2pi, 20)]
colors = 1:20
scatter!(scene, points, color = colors, markersize = 15)

Edit: I found how to put an image onto the plot area. But I don't know how to crop a part of the load image. So that I can put each cropped sub image onto the plot area.

enter image description here

using GLMakie
using AbstractPlotting
using FileIO

img = rotr90(load("assets/cow.png"))

image(img)

Questioner
skatori
Viewed
0
Simon Danisch 2020-12-04 23:18:37

With GLMakie.jl as a backend, you can pass an array of images to marker (or was it color?)!