Bug 16051 - overlapping perpendicular axis labels
Summary: overlapping perpendicular axis labels
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: R 3.1.2
Hardware: Other Linux
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-10-30 21:00 UTC by Sushila
Modified: 2014-11-04 16:25 UTC (History)
1 user (show)

See Also:


Attachments
example of plot with overlapping perpendicular axis labels (3.43 KB, image/png)
2014-10-30 21:03 UTC, Sushila
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sushila 2014-10-30 21:00:48 UTC
When perpendicular axis labels are used, they can overlap. (las=2 or las=1 on the y-axis or las=3 on the x-axis)

Example:

par(mar=rep(4, 4))
layout(matrix(1), widths=lcm(7), heights=lcm(7))
plot(1:300, 1:300, las=2)


When the default (parallel to the axis) labels are used, overlapping labels are removed so that not every tick has a label. (e.g. same as above but remove las=2 from plot to use default las=0).


In case this is device specific - to reproduce the effect I used layout to generate a plot of fixed size that is as small as possible but doesn't give the error "Error in plot.new() : figure margins too large"

It was sometimes necessary to reset the graphics device after getting the above error.


I haven't looked at the code but it seems that the function that plots the axis labels either (1) doesn't check for overlap with perpendicular labels or (2) severely underestimates character height.
Comment 1 Sushila 2014-10-30 21:03:16 UTC
Created attachment 1678 [details]
example of plot with overlapping perpendicular axis labels
Comment 2 Duncan Murdoch 2014-11-04 16:25:07 UTC
I've taken a look at this, but I don't like the results when I make the obvious change.  The problem is that we don't have good information on the height of a string, so we tend to over-estimate it.  This means that if I use the estimated height to detect overlap, I end up leaving out more labels than necessary, and it doesn't look good.

The only suggestion I have is that you can use cex.axis to reduce the font size and avoid overlap, or draw the axis using the axis() function, manually removing some labels.

I'm not going to make any changes or close this; it would be nice to fix it eventually.