Re: Pgfplots: utilizzare simbolo % nell’asse delle ascisse

#59917
admin
Amministratore del forum
    Up
    0
    Down
    ::

    Buongiorno a tutti,
    innanzitutto mi presento: mi chiamo Alessandro e sono un felice utente (base) Latex da alcuni anni.
    In questo periodo sono alle prese con la tesi e tutte le guide ed i post sul forum sono stati preziosi per risolvere i problemi che si sono presentati.
    Non riesco a correggere l’errore che ottengo compilando questo codice:

    `
    \begin{figure}[!htbp]
    \centering
    \begin{tikzpicture}
    \begin{axis}[
    symbolic x coords={control, 3\%, 6\%, 9\%, 12\%, 15\%},
    xtick=data,
    tick label style={
    /pgf/number format/1000 sep=},
    ylabel=\textbf{n. of strains},
    xlabel=\textbf{ethanol \% (v/v)},
    nodes near coords,
    point meta=y,
    legend style={at={(0.5,-0.15)},
    anchor=north,legend columns=-1},
    ybar,
    bar width=15pt,
    ]
    \addplot %positive
    coordinates {(control,87) (3\%,76) (6\%,58) (9\%,43) (12\%,19) (15\%,13)};
    \addplot %negative
    coordinates {(control,0) (3\%,11) (6\%,29) (9\%,44) (12\%,68) (15\%,74)};

    \legend{positive, negative}
    \end{axis}
    \end{tikzpicture}
    \caption{Growth of yeast strain on lab media containing ethanol. The results are expressed as number of strain able (positive) or not able (negative) to grow.}
    \label{gra:ethanol}
    \end{figure}
    `

    Durante la compilazione, per tutti i %, ottengo:
    `

    ! Missing \endcsname inserted.

    \%
    l.21 …1) (6\%,29) (9\%,44) (12\%,68) (15\%,74)};
    `

    Premendo invio a tutti gli errori il grafico viene compilato comunque correttamente.
    Sapreste aiutarmi?
    Grazie

    Prova questo
    `\begin{figure}
    \centering
    \begin{tikzpicture}
    \begin{axis}[
    symbolic x coords={control, 3, 6, 9, 12, 15},
    xticklabels={control,3\%,6\%,9\%,12\%,15\%},
    xtick=data,
    tick label style={
    /pgf/number format/1000 sep=},
    ylabel=\textbf{n. of strains},
    xlabel=\textbf{ethanol \% (v/v)},
    nodes near coords,
    point meta=y,
    legend style={at={(0.5,-0.2)},
    anchor=north,
    legend columns=-1},
    ybar,
    bar width=15pt,
    ]
    \addplot %positive
    coordinates {(control,87) (3,76) (6,58) (9,43) (12,19) (15,13)};
    \addplot %negative
    coordinates {(control,0) (3,11) (6,29) (9,44) (12,68) (15,74)};

    \legend{positive, negative}
    \end{axis}
    \end{tikzpicture}
    \caption{Growth of yeast strain on lab media containing ethanol. The results are expressed as number of strain able (positive) or not able (negative) to grow.}
    \label{gra:ethanol}`
    Ciao
    Orlando

    Go to top