# Errorbar with Adjusted Tick Size 3

Posted by **Jiro Doke**,

Jiro's pick this week is Errorbar with Adjusted Tick by Arnaud Laurent.

Just this week, I got a comment from Felipe on a guest post ("Making Pretty Graphs") that I did on Loren's blog. He pointed out this function by Arnaud that helps adjust the size of the horizontal ticks at
the top and bottom of the `errorbars` that I had to fix manually in the post. Thanks Felipe for the tip!

The `errorbar` automatically determines the tick size based on the limits of the axes, and there is no simple option to change that. However,
the function can return a handle to `errorbarseries`, and you can modify the tick size by digging into its properties. That's what I did in my blog post. Now, it's even easier
with Arnaud's `errorbar_tick`. I echo Felipe's comment on the entry page that it's nice how `errorbar_tick` works on the handle returned by the `errorbar` function, rather than recreating the functionality available in `errorbar`.

Create a standard `errorbar` plot:

x = 1:10; y = sin(x); e = std(y)*ones(size(x)); h = errorbar(x,y,e, 'o-'); set(h, 'MarkerSize', 10, 'MarkerFaceColor', [.3 1 .3], ... 'MarkerEdgeColor', [0 .5 0]);

Apply `errorbar_tick` to increase tick size:

errorbar_tick(h, 30);

**Comments**

Let us know what you think here or leave a comment for Arnaud.

Get the MATLAB code

Published with MATLAB® 7.13

**Category:**- Picks

### Note

Comments are closed.

## 3 CommentsOldest to Newest

**1**of 3

Hi Jiro,

You might find my little updateErrorBars.m tweak on this to be useful. It registers a callback to redraw the error bar widths when the figure is zoomed. I like this because it makes it easy to distinguish a bunch of similar data points because when one zooms in, the error bars no longer overlap.

http://www.mathworks.com/matlabcentral/fileexchange/33734

C.

**2**of 3

Hi Chris,

Yes, I noticed your entry. It’s very nice! I have one comment about the implementation. I’ll post it on your entry page.

Thanks for doing some collaborative work and letting us know about it!

**3**of 3

Dear Jiro,

I am a researcher working at the Swiss Federal Institute of Technology (ETH) Zurich. I am writing since I use regularly your grabit.m program, but I have noticed that it lacks the capability of acquiring data from logarithmic plots.

Please find below some suggestions on how to implement this long missing option. I have tested it and it seems to work fine.

Best regards

Toni Shiroka

% grabit in logarithmic units. By Toni Shiroka, 11.11.2011. % % Let x1 and x2 be two reference points. % The basic idea is that the relative distance of a new point from the origin x1 when expressed in % linear (e.g. pixel) (x2p-x1p) units is the same as the relative distance between the respective % LOGARITHMS, if the scale is logarithmic: % rel_dist = (xnp-x1p)/(x2p-x1p) % in linear units % rel_dist = (log10(xn) - log10(x1)) / (log10(x2) - log10(x1)) % in log units % By solving for xn, one find the expression below. % % The formula con be generalized to natural logarithms by replacing log10 with log. % Of course, one can use it also for semilogx, semilogy, and loglog plots. x1 = 50; % x1 value as shown in graphic (read it from image) x2 = 500; % x2 value as shown in graphic (read it from image) x1p = 45; % x1 value in pixels units (from ginput) x2p =100; % x2 value in pixels units (from ginput) xnp = 78; % x of NEW point in pixels (from ginput). Corresponds to 200 on graphic. % rel_dist = (xnp-x1p)/(x2p-x1p); %relative distance of new point from x1 in (x2p-x1p) units % x of NEW point calculated in graphic units xn = 10^(log10(x2/x1)*(xnp-x1p)/(x2p-x1p) + log10(x1)) % <<---- MAIN FORMULA % Equivalent formulas to the above: % xn = x1*10^(log10(x2/x1)*rel_dist); % xn = x1*10^(log10(x2/x1)*(xnp-x1p)/(x2p-x1p));

## Recent Comments