- Questo topic ha 3 risposte, 2 partecipanti ed è stato aggiornato l'ultima volta 14 anni, 4 mesi fa da .
-
Topic
-
Salve a tutti, ho una domanda, vorrei modificare lo stile delle etichette sull’asse x di un grafico ottenuto con pgfplots. Ho provato con il codice seguente, ma non riesco ad avere le etichette con font sgraziato e più piccolo. Inoltre vorrei aggiungere un po di spazio tra gli elementi della legenda.
`\documentclass[a4paper,12pt]{scrreprt}\usepackage{pgfplots}
\usepackage{siunitx}
\usetikzlibrary{plotmarks}
\pgfplotsset{width=0.82\textwidth,compat=1.5.1,
every axis/.append style={font= {\em\footnotesize}},
every tick label/.append style={font={\sffamily\footnotesize}},
every axis legend/.append style={
draw=none,at={(1.03,0.5)},
anchor=west,font={\sffamily\footnotesize}
}
}
\tikzset{mark size=0.8ex}\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
legend style={
nodes={text width=0.15\textwidth,text depth=}
},
grid=major,
yticklabels=\empty,
axis x line=bottom,
axis y line=left,
xtick align=outside,
xmin=0, xmax=140,
ymin=0, ymax=6,
xtick={0,20,…,140},
ytick={0,1,…,6},
ymajorticks=false,
grid style={loosely dashed, gray!40},
xlabel={x, \si{\watt}},ylabel={y, \si{\newton}}
]
\addplot[
scatter/classes={a={mark=square*,fill=orange,draw=orange!60!white},%
b={mark=diamond*,fill=blue,draw=blue!60!white},%
c={mark=triangle*,fill=green!60!black,draw=green!80!black},%
d={mark=o,draw=blue,mark size=1.3ex},%
e={mark=o,draw=red,mark size=1.3ex},
f={mark=*,black,mark size=0.2ex}},%
scatter,only marks, scatter src=explicit symbolic] table[x=x,y=y,meta=Label] {prova.txt};
\legend{{Primo Elemento},
{Secondo Elemento},
{Terzo Elemento},
{Nota 1},
{Nota 2}}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}`Il file di testo da cui vengono caricati i punti è così composto
`ID x y Label
1 122.7 3.6 a
2 93.8 2.3 a
3 60.2 0.6 a
4 38.7 2.6 a
5 30 1.4 b
6 26.9 2.9 b
7 80.4 5.7 b
8 60.4 3.9 b
9 84.8 3.5 a
10 69.4 3.3 a
11 58.8 1.9 a
12 73.7 2.8 a
13 70.6 2.8 a
14 67.7 3.5 a
15 58.8 2.8 a
16 58.1 3.1 a
17 76.4 2.2 c
18 66.6 1.9 c
19 74.9 2.2 c
20 65.2 2 c
21 70.6 1.6 c
22 72.5 1.6 c
23 122.7 3.6 d
24 93.8 2.3 d
25 60.2 0.6 d
26 38.7 2.6 d
27 30 1.4 d
28 26.9 2.9 d
29 80.4 5.7 d
30 60.4 3.9 d
31 122.7 3.6 e
32 80.4 5.7 e
33 60.4 3.9 e
34 84.8 3.5 f
35 67.7 3.5 f
`
Ogni aiuto sarà estremamente apprezzato.ciao,
Roberto
- Devi essere connesso per rispondere a questo topic.