JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.83k stars 354 forks source link

Long, rotated x-axis tick labels can be cut off in GR #2107

Open asinghvi17 opened 5 years ago

asinghvi17 commented 5 years ago
# setup
using Dates
x = DateTime(2001):Dates.Year(1):DateTime(2005)
y = 1:5
z = rand(5,5)
heatmap(x, y, z, title = "Heatmap with DateTime", xformatter = Plots.dateformatter, xrotation = 90)

90

heatmap(x, y, z, title = "Heatmap with DateTime", xformatter = Plots.dateformatter, xrotation = 45)

45

heatmap(x, y, z, title = "Heatmap with DateTime", xformatter = Plots.dateformatter, xrotation = 20)

20

It's worth noting that saving any of these causes GKS: invalid bitmap size to be printed to terminal.

daschw commented 5 years ago

Some of this (e.g. GKS: invalid bitmap size) might have been introduced by https://github.com/JuliaPlots/Plots.jl/pull/2018. I actually tried to fix the rotated ticks label bug in that PR, but apparently it did not work / cover all cases. The relevant code is probably here: https://github.com/JuliaPlots/Plots.jl/blob/84c5b67574a034ff166c34dca9e2d655a931b36e/src/backends/gr.jl#L713-L772

DesmondYuan commented 3 years ago

Support for this feature is needed! Any updates or workarounds yet?

BoZenKhaa commented 2 years ago

I think as a workaround, you can use

using Plots.PlotMeasures

and then

plot(..., top_margin=10mm, left_margin = 4mm, bottom_margin=3mm, right_margin=7mm)

or just margin.