K. Claesson
K. Claesson

Reputation: 659

Changing scale of axes in Julia

I am importing some numbers from two CSV files and plotting a heatmap according to the below code

height = readdlm("./height.csv", ';', Float64)
deformation = readdlm("./deformation.csv", ';', Float64)
heatmap(10^9 .* (height - deformation), 
   aspect_ratio=:equal,
   title="Height - Deformation")

The plotting libraries that I have used to do this are GR and Plotly with the Plots meta package. Currently, the x-axis and y-axis of the heatmap consists of 256 units of length. It is possible to change the scale of the x-axis and y-axis. For instance, could I make each tick on the x-axis have length 256/900 of the current unit length?

Upvotes: 0

Views: 1573

Answers (1)

hckr
hckr

Reputation: 5583

You can use heatmap(x, y, z) for this.

I suppose you have 256 entries in each dimension and a total of 65536 entries.

x = 1/256:1/256:1 # an iterable with length 256
y = 1/256:1/256:1 # an iterable with length 256

heatmap(x, y, 10^9 .* (height - deformation))

This way each rectangle will have 1/256 unit width and 1/256 unit height. You may assign x and y to any other iterable so long as each of them contains 256 entries. You can even set them as arrays of strings.

You can set actual ticks using an iterator with xticks or yticks keyword arguments in a similar manner.

Upvotes: 1

Related Questions