Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pgfplots: set 'line width' for plots only

4,641 views
Skip to first unread message

Leo

unread,
May 20, 2009, 7:16:54 AM5/20/09
to
Hi group,

I am using pgfplots for plots. There is one thing I don't know how to
change and it makes the graph rather ugly.

When I set the line width to 2 pt, the underlying canvas (the axis) also
has a line width 2 pt. See this image: http://imagebin.org/49669.

Is there an easy way to set the plots line width only without affecting
the axis?

Incidentally, if the mark is hollow like mark=o, is there a way not to
have the line go through it? At the moment, I am using solid marker and
fill it with a white color.

Thank you.

Example as follows

--8<---------------cut here---------------start------------->8---
\documentclass[10pt]{scrartcl}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[british]{babel}

\usepackage{tikz}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}[every mark/.append style={fill=white,scale=1.5}]
\begin{axis}
[
cycle list name=color,
line width=2pt,
ymin=0,
width=10cm,
height=7cm,
]
\addplot [mark=*,blue] coordinates {
(0,9.22)
(1,9.08)
(2,9.09)
(3,8.8)
(4,8.06)
};
\end{axis}
\end{tikzpicture}
\end{document}
--8<---------------cut here---------------end--------------->8---


--
.: Leo :. [ sdl.web AT gmail.com ] .: I use Emacs :.

Leo

unread,
May 20, 2009, 7:21:18 AM5/20/09
to
On 2009-05-20 12:16 +0100, Leo wrote:
> When I set the line width to 2 pt, the underlying canvas (the axis) also
> has a line width 2 pt. See this image: http://imagebin.org/49669.

and this one http://imagebin.org/49671 is what the example looks like.

Leo

unread,
May 20, 2009, 8:25:09 AM5/20/09
to
On 2009-05-20 12:16 +0100, Leo wrote:
[...]

> Is there an easy way to set the plots line width only without affecting
> the axis?

I found the answer: every axis plot/.append style={......}.

> Incidentally, if the mark is hollow like mark=o, is there a way not to
> have the line go through it? At the moment, I am using solid marker
> and fill it with a white color.

Any hint on this one?

> Thank you.

Theo Markettos

unread,
May 21, 2009, 11:27:39 AM5/21/09
to
Leo <sdl...@gmail.com> wrote:
> On 2009-05-20 12:16 +0100, Leo wrote:
> > Incidentally, if the mark is hollow like mark=o, is there a way not to
> > have the line go through it? At the moment, I am using solid marker
> > and fill it with a white color.
>
> Any hint on this one?

What do you want that a white solid marker doesn't provide?

Having the line stop either side of the marker is a bit tricky... if you
think about a circular marker, to do it properly you'd have to cut a
semicircle out of the end of the (thick) line so that at all zoom factors
there was no gap between the end of the line and the marker, and no spill of
the line inside. Overlaying a solid marker on top would seem to be much
easier.

Theo

Leo

unread,
May 21, 2009, 4:54:29 PM5/21/09
to

The only thing I can think of that it does not offer is in cases where
the background color is unknown beforehand.

PGFPLOTS is about the only thing from tikz I use. So forgive my
ignorance. Don't you think that clipping can be employed in
implementing this feature?

I have seen other charting software that either connect to the edge of
the marker or leave a gap. They look beautiful actually.

> Theo

Theo Markettos

unread,
May 23, 2009, 2:01:30 PM5/23/09
to
Leo <sdl...@gmail.com> wrote:
> The only thing I can think of that it does not offer is in cases where
> the background color is unknown beforehand.
>
> PGFPLOTS is about the only thing from tikz I use. So forgive my
> ignorance. Don't you think that clipping can be employed in
> implementing this feature?

OK. You may be able to define a node that first plots the marker in
clipping mode, then plots the real shape on top. Have a look at \clip in
the tikz/pgf manual.

I'm afraid I don't have any experience with this, but it looks reasonably
straightforward (once you've got the syntax right).

Theo

0 new messages