Liverpool” post=97505
1. Perché la griglia delle help lines è sfalsata rispetto al piano cartesiano?
[tt]grid[/tt] è un’istruzione di TikZ, non di pgfplots. Il passo della griglia è di 1 cm per default. Invece l’unità di misura del grafico non è 1 cm, ma dipende anche dal valore di [tt]width[/tt]. Il risultato è che la griglia è sfasata rispetto al grafico.
Di per sé pgfplots ha una chiave per disegnare la griglia, che si chiama proprio [tt]grid[/tt]. Io userei quella, ma nel tuo caso non funziona. Perché? Perché hai scelto di non mostrare le tacche sull’asse y. Ma allora uno si chiede: che senso ha aggiungere la griglia e rimuovere le tacche sull’asse y? Forse dovresti ripensarci: lasciare le tacche e rimuovere solo le etichette.
E quindi? Che cosa devo fare in concreto per disegnare quella griglia? Insomma, vorrei poter evitare cose del tipo:
`\begin{tikzpicture}[font=\small]
\begin{axis} [width=0.7\textwidth,scale mode=scale uniformly,
axis lines=middle,
xmin=-5,xmax=5,ymin=-1,ymax=5,
enlargelimits,
xtick=\empty,
ytick=\empty,
xlabel=$x$,
ylabel=$y$]
\draw [help lines] (axis cs:-6,-10) — (axis cs:-6,10);
\draw [help lines] (axis cs:-5,-10) — (axis cs:-5,10);
\draw [help lines] (axis cs:-4,-10) — (axis cs:-4,10);
\draw [help lines] (axis cs:-3,-10) — (axis cs:-3,10);
\draw [help lines] (axis cs:-2,-10) — (axis cs:-2,10);
\draw [help lines] (axis cs:-1,-10) — (axis cs:-1,10);
\draw [help lines] (axis cs:1,-10) — (axis cs:1,10);
\draw [help lines] (axis cs:2,-10) — (axis cs:2,10);
\draw [help lines] (axis cs:3,-10) — (axis cs:3,10);
\draw [help lines] (axis cs:4,-10) — (axis cs:4,10);
\draw [help lines] (axis cs:5,-10) — (axis cs:5,10);
\draw [help lines] (axis cs:6,-10) — (axis cs:6,10);
\draw [help lines] (axis cs:-10,-6) — (axis cs:10,-6);
\draw [help lines] (axis cs:-10,-5) — (axis cs:10,-5);
\draw [help lines] (axis cs:-10,-4) — (axis cs:10,-4);
\draw [help lines] (axis cs:-10,-3) — (axis cs:10,-3);
\draw [help lines] (axis cs:-10,-2) — (axis cs:10,-2);
\draw [help lines] (axis cs:-10,-1) — (axis cs:10,-1);
\draw [help lines] (axis cs:-10,1) — (axis cs:10,1);
\draw [help lines] (axis cs:-10,2) — (axis cs:10,2);
\draw [help lines] (axis cs:-10,3) — (axis cs:10,3);
\draw [help lines] (axis cs:-10,4) — (axis cs:10,4);
\draw [help lines] (axis cs:-10,5) — (axis cs:10,5);
\addplot [domain=-5:5, samples=999, restrict y to domain=-30:30,smooth,thick] {sqrt(16-x^2)};
\draw (axis cs:4,0) [blue,fill=blue,very thick] circle (2.0pt);
\draw (axis cs:-4,0) [blue,fill=blue,very thick] circle (2.0pt);
\end{axis}
\end{tikzpicture}`
Un altro problema. Come disegno la radice cubica? Il meglio che ho trovato è:
`\begin{tikzpicture}[font=\small]
\begin{axis} [width=0.4\textwidth,
axis lines=middle,
xmin=-5,xmax=5,ymin=-2,ymax=2,
enlargelimits,
xtick=\empty,
ytick=\empty,
xlabel=$x$,
ylabel=$y$,
title={$y=\sqrt[n]{x}$, $n$ naturale dispari $\ge1$}]]
\addplot [domain=0:6, samples=999, restrict y to domain=-30:30,smooth,grafico] {e^(ln(x)/3)};
\addplot [domain=-6:0, samples=499, restrict y to domain=-30:30,smooth,grafico] {-e^(ln(abs(x))/3)};
\end{axis}
\end{tikzpicture}`
Suggerimenti per migliorare il codice ma soprattutto il risultato?
Grazie mille! 🙂