Re: Stupire con effetti speciali e colori ultravivaci

#97090
Up
0
Down
::

lorenzo.pantieri” post=97492

Se riesci a postare il codice di una delle figure sarebbe un ottimo punto di partenza.

Ecco qui:
`\begin{tikzpicture}[font=\small]
\begin{axis} [width=0.55\textwidth,
axis lines=middle,
xmin=-1.6,xmax=1.6,ymin=-1,ymax=4,
enlargelimits,
xtick={-1.414,-1,-0.577,0.577,1,1.414},
xticklabels={$-\sqrt{2}$,$-1$,,,$1$,$\sqrt{2}$},
ytick={-1},
xlabel=$x$,
ylabel=$y$]

% minimi
\draw [dashed] (axis cs:1,0) — (axis cs:1,-1);
\draw [dashed] (axis cs:1,-1) — (axis cs:0,-1);

\draw [dashed] (axis cs:-1,0) — (axis cs:-1,-1);
\draw [dashed] (axis cs:-1,-1) — (axis cs:0,-1);

\addplot [domain=-2:2, samples=200, restrict y to domain=-30:30,smooth,grafico] {x^4-2*x*x};

\pattern [pattern= north east lines, pattern color=lightgray] (axis cs:1.414,-6) rectangle (axis cs:4,0);
\pattern [pattern= north east lines, pattern color=lightgray] (axis cs:-1.414,0) rectangle (axis cs:1.414,6);
\pattern [pattern= north east lines, pattern color=lightgray] (axis cs:-1.414,0) rectangle (axis cs:-4,-6);

\draw [dashed] (axis cs:1.414,-6) — (axis cs:1.414,6);
\draw [dashed] (axis cs:-1.414,-6) — (axis cs:-1.414,6);

% zeri
\draw (axis cs:1.414,0) [blue,fill=blue,very thick] circle (2.0pt);
\draw (axis cs:-1.414,0) [blue,fill=blue,very thick] circle (2.0pt);
\draw (axis cs:0,0) [blue,fill=blue,very thick] circle (2.0pt);

% minimi
\draw (axis cs:1,-1) [blue,fill=blue,very thick] circle (2.0pt);
\draw (axis cs:-1,-1) [blue,fill=blue,very thick] circle (2.0pt);

% flessi
\draw (axis cs:0.577,-0.556) [blue,fill=blue,very thick] circle (2.0pt);
\draw (axis cs:-0.577,-0.556) [blue,fill=blue,very thick] circle (2.0pt);

% minimi
\node [below] at (axis cs:1,-1) {$\min$};
\node [below] at (axis cs:-1,-1) {$\min$};
\node [above] at (axis cs:0,0) {$\max$};

% flessi
\node [above] at (axis cs:0.577,-0.556) {$\flex$};
\node [above] at (axis cs:-0.577,-0.556) {$\flex$};
\end{axis}
\end{tikzpicture}`
I vostri suggerimenti sono più che benvenuti!

Una risposta parziale, visto che l’esempio è parziale (non conosco lo stile [tt]grafico[/tt] e neppure il comando [tt]\flex[/tt]). Purtroppo, per questo motivo non ho potuto risolvere il problema che accennavo sul segmento che disegna le funzioni: probabilmente queste direttive sono contenute nel misterioso stile [tt]grafico[/tt].

Per prima cosa ho personalizzato il pattern secondo queste linee guida. Personalizzare il tipo north east lines è qualcosa di analogo, ma si potrà fare quando il codice è completo (per chi vuole cimentarsi consiglio di partire dal codice originale che se ben ricordo è in [tt]pgflibrarypatterns.code.tex[/tt]).

Seconda cosa ho inserito il pattern in background per evitare che copra le etichette; in questo caso è anche necessario un clip ulteriore sulla tela del grafico. Il risultato in linea di massima è migliore.

[attachment=1157]ScreenShot2014-10-31at9.04.31AM.png[/attachment]

Il codice: `\documentclass[tikz,border=10pt]{standalone}
\usepackage{amsmath,amssymb,pgfplots}
\usetikzlibrary{backgrounds,patterns}
\tikzset{grafico/.style={}}
\newcommand{\flex}{\textrm{boh}}

% defining the new dimensions and parameters
\newlength{\hatchspread}
\newlength{\hatchthickness}
\newlength{\hatchshift}
\newcommand{\hatchcolor}{}
% declaring the keys in tikz
\tikzset{hatchspread/.code={\setlength{\hatchspread}{#1}},
hatchthickness/.code={\setlength{\hatchthickness}{#1}},
hatchshift/.code={\setlength{\hatchshift}{#1}},% must be >= 0
custom pattern color/.code={\renewcommand{\hatchcolor}{#1}}}
% setting the default values
\tikzset{hatchspread=3pt,
hatchthickness=0.4pt,
hatchshift=0pt,% must be >= 0
custom pattern color=black}
% declaring the pattern
\pgfdeclarepatternformonly[\hatchspread,\hatchthickness,\hatchshift,\hatchcolor]% variables
{custom north west lines}% name
{\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner
{\pgfqpoint{\dimexpr\hatchspread+2\hatchthickness}{\dimexpr\hatchspread+2\hatchthickness}}% upper right corner
{\pgfqpoint{\dimexpr\hatchspread}{\dimexpr\hatchspread}}% tile size
{% shape description
\pgfsetlinewidth{\hatchthickness}
\pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\hatchspread+\hatchshift}}
\pgfpathlineto{\pgfqpoint{\dimexpr\hatchspread+0.15pt+\hatchshift}{-0.15pt}}
\ifdim \hatchshift > 0pt
\pgfpathmoveto{\pgfqpoint{0pt}{\hatchshift}}
\pgfpathlineto{\pgfqpoint{\dimexpr0.15pt+\hatchshift}{-0.15pt}}
\fi
\pgfsetstrokecolor{\hatchcolor}
% \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way
\pgfusepath{stroke}
}

\begin{document}
\begin{tikzpicture}[font=\small]
\begin{axis} [width=0.55\textwidth,
axis lines=middle,
xmin=-1.6,xmax=1.6,ymin=-1,ymax=4,
enlargelimits,
xtick={-1.414,-1,-0.577,0.577,1,1.414},
xticklabels={$-\sqrt{2}$,$-1$,,,$1$,$\sqrt{2}$},
ytick={-1},
xlabel=$x$,
ylabel=$y$,
title={Nessuno crea esempi minimi completi}]

% minimi
\draw [dashed] (axis cs:1,0) — (axis cs:1,-1);
\draw [dashed] (axis cs:1,-1) — (axis cs:0,-1);

\draw [dashed] (axis cs:-1,0) — (axis cs:-1,-1);
\draw [dashed] (axis cs:-1,-1) — (axis cs:0,-1);

\addplot [domain=-2:2, samples=200, restrict y to domain=-30:30,smooth,grafico] {x^4-2*x*x};

\begin{scope}[on background layer, my pattern/.style={pattern=custom north west lines,hatchspread=5pt,hatchthickness=.5pt, custom pattern color=lightgray}]
\clip (current axis.south west) rectangle (current axis.north east);
\pattern [my pattern] (axis cs:1.414,-6) rectangle (axis cs:4,0);
\pattern [my pattern] (axis cs:-1.414,0) rectangle (axis cs:1.414,6);
\pattern [my pattern] (axis cs:-1.414,0) rectangle (axis cs:-4,-6);
\end{scope}

\draw [dashed] (axis cs:1.414,-6) — (axis cs:1.414,6);
\draw [dashed] (axis cs:-1.414,-6) — (axis cs:-1.414,6);

% zeri
\draw (axis cs:1.414,0) [blue,fill=blue,very thick] circle (2.0pt);
\draw (axis cs:-1.414,0) [blue,fill=blue,very thick] circle (2.0pt);
\draw (axis cs:0,0) [blue,fill=blue,very thick] circle (2.0pt);

% minimi
\draw (axis cs:1,-1) [blue,fill=blue,very thick] circle (2.0pt);
\draw (axis cs:-1,-1) [blue,fill=blue,very thick] circle (2.0pt);

% flessi
\draw (axis cs:0.577,-0.556) [blue,fill=blue,very thick] circle (2.0pt);
\draw (axis cs:-0.577,-0.556) [blue,fill=blue,very thick] circle (2.0pt);

% minimi
\node [below] at (axis cs:1,-1) {$\min$};
\node [below] at (axis cs:-1,-1) {$\min$};
\node [above] at (axis cs:0,0) {$\max$};

% flessi
\node [above] at (axis cs:0.577,-0.556) {$\flex$};
\node [above] at (axis cs:-0.577,-0.556) {$\flex$};
\end{axis}
\end{tikzpicture}

\end{document}`

Ciao
Claudio

Attachments:
You must be logged in to view attached files.

Go to top