Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way to eliminate the bold lines on the x and y axes of this R line plot?

I am plotting very basic data from a .CSV in Posit Cloud. The plot itself looks how I want it to, but the x and y axes both have a bit of bolding along the middle of the axis lines, and I would like to remove these. The problem can be seen in the first image below, and I’ve highlighted the bolder part in the image below it.

bold parts highlighted

An example of the code that reproduces the issue and is the same code as mine (minus the data):

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

#base R plot definition
plot(
  #define axes
  x= 1:13, 
  y= 3:15,
  
  #customise axes
  xaxs = "i", 
  yaxs = "i",
  type="l", 
  col="#32a852", 
  bty = "l",
  
  #labels
  xlab = 'Bias Current [mA]', 
  ylab = "Voltage [V]", 
  main ="IV Characteristic of 1270nm Laser")

I realise that the axes do not both start at 0, and if they did, then this wouldn’t be an issue, but I don’t want to add dead space into the plot.

I have tried removing the axes by setting axes=FALSE in the plot definition, and then adding the axes back in separately, but I ended up with the same result, but produced in a more complex way.

>Solution :

The issue is overplotting of the box and the axis line. As mentioned in comments, the AGG graphics device provided in the ragg package might solve the issue. If not, you can plot the axis ticks without the lines:

plot(
  #define axes
  x= 1:13, 
  y= 3:15,
  
  #customise axes
  xaxs = "i", 
  yaxs = "i",
  type="l", 
  col="#32a852", 
  axes = FALSE,
  
  #labels
  xlab = 'Bias Current [mA]', 
  ylab = "Voltage [V]", 
  main ="IV Characteristic of 1270nm Laser")

box(bty = "l")
axis(side = 1, lwd = 0, lwd.ticks = 1)
axis(side = 2, lwd = 0, lwd.ticks = 1)

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading