Setting size resolution of makie plot when plotting

When working with Julia and plotting using the Makie package, you may come across the need to set the size resolution of your plot. This can be useful when you want to control the size of the plot window or when you want to save the plot as an image with a specific resolution. In this article, we will explore three different ways to solve this problem.

Option 1: Using the `size` argument

The first option is to use the `size` argument when creating the plot. This argument allows you to specify the size of the plot window in pixels. Here’s an example:


using Makie

# Create a plot with a specific size
scene = Makie.scatter(rand(100), rand(100), size = (800, 600))

In this example, we create a scatter plot with a size of 800 pixels by 600 pixels. You can adjust the values to fit your specific needs.

Option 2: Using the `dpi` argument

The second option is to use the `dpi` argument when saving the plot as an image. This argument allows you to specify the resolution of the saved image in dots per inch (dpi). Here’s an example:


using Makie

# Create a plot
scene = Makie.scatter(rand(100), rand(100))

# Save the plot as an image with a specific resolution
save(scene, "plot.png", dpi = 300)

In this example, we save the plot as an image with a resolution of 300 dpi. You can adjust the value to fit your specific needs.

Option 3: Using the `figure` function

The third option is to use the `figure` function to create a plot window with a specific size. Here’s an example:


using Makie

# Create a plot window with a specific size
figure(size = (800, 600))

# Create a plot
scene = Makie.scatter(rand(100), rand(100))

In this example, we create a plot window with a size of 800 pixels by 600 pixels and then create a scatter plot within that window. You can adjust the values to fit your specific needs.

After exploring these three options, it is clear that the best option depends on your specific requirements. If you only need to control the size of the plot window, option 1 or option 3 would be suitable. On the other hand, if you need to save the plot as an image with a specific resolution, option 2 would be the better choice.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents