Gadfly.jl icon indicating copy to clipboard operation
Gadfly.jl copied to clipboard

Provide a way to draw tick marks

Open felixjung opened this issue 10 years ago • 6 comments

I like the ggplot approach taken by Gadfly. However, I dearly miss the ability to draw tick marks on my axes. For my publication purposes, I am required to not show grid lines and instead draw tick marks on the axes. Is there a specific reason they are missing at the moment?

felixjung avatar Jun 19 '14 23:06 felixjung

It's definitely something that should be added. I like the default look without ticks, but there should be an option add them.

dcjones avatar Jun 21 '14 02:06 dcjones

I'd actually be interest in having a look at implementing some of the features I am missing myself. However, I find it kind of hard to navigate the Gadfly codebase... Where do things like drawing gridlines, drawing the legend etc. happen? It shouldn't be hard to draw ticks if a certain theme variable is set. It also shouldn't be hard to not draw the legend, if a certain variable is set.

felixjung avatar Jun 22 '14 18:06 felixjung

It's definitely not easy to navigate. Grid lines, labels, keys, etc, are all considered guides. They're defined in src/guide.jl. The guide that drawn gridlines and their labels is XTick and YTick. The function responsible for drawing them is called render. I think you're idea of having an option in theme that turns on tick marks on the margin is a good plan.

The render function for guides return arrays of PositionedGuides, which contain the guide graphic along with an indication of where it should be placed relative to the plot (top, right, over, under, etc). The code drawing the gridlines and tick labels is a little tricky because it's also drawing gridlines that initially hidden and get revealed while panning or zooming, but I think for ticks you can mimic how the gridlines are drawn and just set them to be positioned below or to the left of the plot with under_guide_position and left_guide_position.

Let me know if you get stuck on anything.

dcjones avatar Jun 23 '14 02:06 dcjones

Cool, I have a look. I have also noticed that the gridlines are somehow drawn above the panel's border. Thus, when setting panel_stroke to a dark color, the border will be interrupted by the gridlines. I think it should be the other way around.

Thanks for the hints.

felixjung avatar Jun 23 '14 07:06 felixjung

I agree that the grid lines should be under the border. The issue is that the border is drawn by just stroking the background rectangle in a different color, and the background of course under the grid lines, so I should add a separate border rectangle that's above everything.

dcjones avatar Jun 23 '14 16:06 dcjones

Hi all, I just started working with Julia. I would need ticks marks without grid lines and up to date it seems this was not implemented. Any of you can help me?

rtambone avatar Jul 06 '21 09:07 rtambone