MHB Efficiently Scale Pictures in TikZ with Simple Code | No Quotation Marks

  • Thread starter Thread starter karush
  • Start date Start date
  • Tags Tags
    Picture Scaling
AI Thread Summary
The discussion focuses on the proper syntax for scaling a TikZ picture in LaTeX. It emphasizes that the scale parameter should be included within the square brackets of the \begin{tikzpicture} command, alongside any declared functions. The user initially encountered issues with scaling after removing the percentage sign. After clarification, they learned the correct placement of the scale parameter and expressed a desire to add x and y ticks at critical points, noting a preference for more flexibility in tick setup compared to Desmos. The conversation highlights the importance of syntax in LaTeX for achieving desired visual outputs in graphics.
karush
Gold Member
MHB
Messages
3,240
Reaction score
5
as you see from %[scale=0.8]
I tried to scale the picture but it didn't after removing the %

\begin{tikzpicture}%[scale=0.8]
[declare function = {
tilde_y(\q) = sign(\q)*sqrt(abs(\q) / (1 - (abs(\q)-3)^3));},
pics/coordinates/.style args={(#1,#2),(#3,#4)}{ code={
%\draw[help lines] (#1,#2) grid (#3,#4);
\draw[-latex] (#1,0) -- (#3,0);
\draw[-latex] (0,#2) -- (0,#4);
%\node foreach \i in {#1,...,#3} at (\i,-0.1) [ below ] {$\i$};
%\node foreach \i in {#2,...,#4} at (-0.1,\i) [ left ] {$\i$};
}},
every node/.style={fill=black!5},
fill=black!5,]
\pic {coordinates={(-3,-2),(3,4)}};
\begin{scope}[draw=blue, ultra thick]
\draw[domain=-3.5:3.5, variable=\q, smooth] plot ({(abs(\q) - 3) * tilde_y(\q)}, {1 + tilde_y(\q)});
\filldraw foreach \p in {(1,3),(-1,2),(1,0),(-1,-1)} { \p circle (0.06) };
\end{scope}
\end{tikzpicture}
 
Last edited:
Physics news on Phys.org
karush said:
as you see from %[scale=0.8]
I tried to scale the picture but it didn't after removing the %
There are already square brackets after \begin{tikzpicture}, which contain the declare function.
The scale must be inside like [scale=0.8, declare function....
When we do so, we get:
\begin{tikzpicture}
[scale=0.8, declare function = {
tilde_y(\q) = sign(\q)*sqrt(abs(\q) / (1 - (abs(\q)-3)^3));},
pics/coordinates/.style args={(#1,#2),(#3,#4)}{ code={
%\draw[help lines] (#1,#2) grid (#3,#4);
\draw[-latex] (#1,0) -- (#3,0);
\draw[-latex] (0,#2) -- (0,#4);
%\node foreach \i in {#1,...,#3} at (\i,-0.1) [ below ] {$\i$};
%\node foreach \i in {#2,...,#4} at (-0.1,\i) [ left ] {$\i$};
}},
every node/.style={fill=black!5},
fill=black!5,]
\pic {coordinates={(-3,-2),(3,4)}};
\begin{scope}[draw=blue, ultra thick]
\draw[domain=-3.5:3.5, variable=\q, smooth] plot ({(abs(\q) - 3) * tilde_y(\q)}, {1 + tilde_y(\q)});
\filldraw foreach \p in {(1,3),(-1,2),(1,0),(-1,-1)} { \p circle (0.06) };
\end{scope}
\end{tikzpicture}
 
mahalo, yes I didn't know that...
i was going to put x and y ticks in where the critical points are but
but will try from previous examples
don't really need here but just want to see how it works
the one think i didn't like about desmos was the very limited setup for ticks
 

Similar threads

Replies
4
Views
2K
Replies
5
Views
2K
Replies
0
Views
5K
Replies
1
Views
2K
Replies
3
Views
5K
Replies
8
Views
2K
Replies
7
Views
2K
Back
Top