Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase the length of plot tick marks

How can I increase the length of plot tick marks? Here is a small example:

r <- as.POSIXct(round(range(time), "mins"))
plot(time, x, t="l", xaxt = "n")
axis.POSIXct(1, at = seq(r[1], r[2], by = "min"), format = "%H:%M:%S")

which gives

enter image description here

As you can see, all the ticks are the same size. Is there a way to automatically increase the length of those ticks that are signed?

like image 864
user2314809 Avatar asked Apr 24 '13 09:04

user2314809


People also ask

How do I make ticks longer in Matplotlib?

To make longer subplot tick marks in matplotlib, we can use tick_params() method for minor and major ticks length and width.

How do I increase the length of a tick in Matlab?

If you want your tick to be longer and thicker, you can increase both the length AND thickness of the tick marks with the TickLength and LineWidth properties of the axes. ax. TickLength = [k, k]; % Make tick marks longer.

How do you make a tick bigger in R?

To increase the width of axes tick (both X-axis and Y-axis at the same time) using ggplot2 in R, we can use theme function with axis. ticks argument where we can set element_line argument size to a larger value.

What is a tick in a plot?

Ticks are the values used to show specific points on the coordinate axis. It can be a number or a string. Whenever we plot a graph, the axes adjust and take the default ticks. Matplotlib's default ticks are generally sufficient in common situations but are in no way optimal for every plot.


1 Answers

When creating a very specific axis layout, you typically need to add the axis after drawing the plot. Since you didn't have a reproducible example, I've created my own data set.

  1. Create a plot, but don't display the axis

    plot(1:10, axes=FALSE, frame=TRUE)
    
  2. Add in the x-scale. In this example, values 1,2,3, ...., 10. The argument tck specifies the tick length:

    ##The tck value should be smaller here
    axis(1, 1:10, tck=-0.05)
    
  3. Now add in an additional scale for "in-between" values. I've set labels="", so we don't print any values:

    axis(1, seq(0.5, 9.5, 1), labels=rep("", 10), tck=-0.01)
    

This gives:

enter image description here

like image 179
csgillespie Avatar answered Nov 14 '22 15:11

csgillespie