Am 18.12.2011 21:55, schrieb Xavier Scheuer:
> On 18 December 2011 16:19, Christian Feuersaenger
> <cfeuersaen...@googlemail.com>  wrote:
>> Hi Xavier,
>>
>> welcome to "the wonderful world" (and thanks for the praise) :-)
>>
>> You already distilled the right piece of information for your use-case:
>> changing the 'every axis y label' style is precisely what you need.
>>
>> Here is a little bit more background information which hopefully leads to
>> the desired positioning:
>> the 'ticklabel cs:0.5' means that that is is positioned
>> a) on the same axis as tick labels (in your case yticklabels)
>> b) "adjacent" to the tick labels (i.e. leaving enough room such that it does
>> not overlap)
>> c) 50% of the axis containing tick labels (the 0.5).
>>
>> Since you would like to position it at the top of the y axis, you may want
>> to consider 'ticklabel cs:1' or 'ticklabel cs:0.9'.
>>
>> The choice 'anchor=top' means that the "top" position *inside* of the ylabel
>> is placed at the position identified by 'at'.
>> Pgfplots comes with the choice 'anchor=near ticklabel' which might be more
>> adequate here.
>>
>> So, my advice would be
>>
>> every axis y label/.style={at={(ticklabel cs:0.8)},anchor=near ticklabel}
>>
>> perhaps together with a "xshift=-0.2em" or something like that.
>>
>> The interaction between 'at={..}' and 'anchor' is explained in more detail
>> in the tikz manual, but the pgfplots section "Alignment" also explains these
>> concepts (the alignment concept comes with tikz; pgfplots "only" uses it).
>>
>> Your approach with<key>/.style={}  means to replace the style named '<key>'
>> with new options -- in your case the 'every axis y label'.
>> In your use-case, this is precisely what you needed. Note that in general,
>> *appending* new options (like<key>/.append style={}) is the preferred way to
>> change styles - but again, you have the correct approach here.
> Thank you for this fast, complete, efficient and instructive answer.
> Actually I find that changing the value of cs: did mainly what I was
> looking for just after having sent my e-mail.
>
> I am a bit surprised there is no "shortcut setting", "easy option" for
> this.  Is there a way to define this "axis y label/.style" setting
> somewhere "globally", so I do not need to add it for every graph I do?

Hi Xavier,

There is, indeed, a way to define that stuff globally: just collect all 
your options which make up the global configuration and
place them into the document's preamble using \pgfplotsset:

\pgfplotsset{
     every axis y label/.style={...},
<other common key>=<value>,
}

That's it. Settings assigned with \pgfplotsset{} constitue variables 
which remain in effect until the end of the environment in which 
\pgfplotsset was invoked or until the option has been reset manually.

In case you are also interested in my personal experience with such 
global settings, here are a couple of best-practises:

a) always use a trailing comma (even for the last option)
b) properly indend your code with one key per line (allows simply 
(un)commenting)
c) consider using named custom styles, i.e.

\pgfplotsset{
    xavier standard/.style={
       every axis y label/.style={...},
<other common key>=<value>,
   },
}

\begin{document}
...
\begin{axis}[xavier standard]
...


Best regards

Christian



------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Pgfplots-features mailing list
Pgfplots-features@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgfplots-features

Reply via email to