# Auto adjust fontsize in Plots.jl

**URL:** <https://discourse.julialang.org/t/auto-adjust-fontsize-in-plots-jl/49276>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [October 30, 2020, 12:50am UTC](https://discourse.julialang.org/t/auto-adjust-fontsize-in-plots-jl/49276 "2020-10-30T00:50:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![libensvivit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libensvivit/32/19006_2.png) [@libensvivit](https://discourse.julialang.org/u/libensvivit)\
**Post date:** [October 30, 2020, 12:50am UTC](https://discourse.julialang.org/t/auto-adjust-fontsize-in-plots-jl/49276/1 "2020-10-30T00:50:25Z")

</div>

In Plots, I’m using custom ticks and save the plot in high resolution with `size` attribute. However, as far as I have seen Plots does not adjust the font size of anything when this attribute is used, and the user has to adjust them manually for different sizes of plots.  
Take a look here for example:

 ![lol](https://global.discourse-cdn.com/julialang/original/3X/4/c/4ccfcbd951538c7dad03475027e2594885d8adb0.jpeg)

Ticks are nearly invisible, but if zoom you can actually see them. Luckily, I found the optimal font size for this plot to be 60. But changing the font size now poses another problem where texts exit the plot and get truncated. Therefore, there should be another 2 variables to adjust, `x_offset` and `y_offset`. Here is a minimal example:

```julia
using Plots, TestImages

arr = hvcat(5,[testimage("cameraman") for i in 1:30]...)

rangeX = range(256; step=512, stop=size(arr)[2])
rangeY = reverse(range(256; step=512, stop=size(arr)[1]))
_xticks = (rangeX, string.(rangeX));
_yticks = (rangeY, string.(rangeY));

x_offset = 100; #if 0, ticks on y axis get truncated
y_offset = 0;
_tickfontsize = 60;

plot(1:size(arr)[2], 1:size(arr)[1], arr,
         xticks=_xticks, yticks=_yticks,
         tickfontsize=_tickfontsize,
         size=(size(arr)[2]+x_offset,size(arr)[1]+y_offset),
         xrotation=70)
png(joinpath(@ __DIR__ ,"img.png"))

```

Is there a workaround for this problem or do I have to manually adjust these parameters for every plot?
