Changing the values of axes without resizing the image/figure in Plots.jl


I have an image of 300x300 pixels loaded in Plots and I’m having a hard time modifying the axes without altering the image. If I change the xlims, the image gets resized. If I try xticks, it gets weird if I pass 300. (My aim is to have very small numbers in the axes, without changing any size of it).


This guy had the same problem in MATLAB, and luckily someone got it fixed. Is there a similar trick to achieve the same thing in Julia?

Could you post your code so far?
Have you tried setting size=(a, b) as a kwarg to plot?

@danielw2904 size you mentioned also changes the size of the image, fonts become smaller and don’t give the expected results.

After loading the image:

img = Images.load("path/to/image.jpg") # 300x300 pixels

I tried the following combinations seperately.
plot(img, ylims=(0, 1000), xlims=(0, 1000));
plot(img, yticks=0:100:1000, xticks=0:100:1000);
plot(img, size=(1000,1000), yticks=0:100:1000, xticks=0:100:1000)

No luck so far. Also, I found that PyPlot.jl has similar adjustments with axes i.e ax = gca(), but it calls Python library and that is something I’m trying to avoid.

You should pass x and y coordinates to plot, e.g.,

x = range(0,1000,length=size(img,1))
y = range(0,1000,length=size(img,2))

Yes!! This is what I really want. Thanks, sir!