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

In summary, the conversation discusses the process of scaling a picture using the TikZ package. The expert summarizer notes that the scale must be placed inside the square brackets after \begin{tikzpicture} and provides an example of how to do so. They also mention that the use of x and y ticks can be limited in Desmos, prompting the original speaker to try using previous examples.
  • #1
karush
Gold Member
MHB
3,269
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
  • #2
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}
 
  • #3
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
 

1. How do I efficiently scale pictures in TikZ?

To efficiently scale pictures in TikZ, you can use the built-in \scalebox command. This command takes two arguments: the scale factor and the content to be scaled. For example, \scalebox{0.5}{\includegraphics{picture}} will scale the picture by 50%.

2. Can I scale pictures in TikZ without using quotation marks?

Yes, you can use the \scalebox command without using quotation marks. Instead, you can use curly braces to enclose the content to be scaled. For example, \scalebox{0.5}{\includegraphics{picture}} can be written as \scalebox{0.5}{\includegraphics{picture}}.

3. Can I use the \scalebox command in conjunction with other TikZ commands?

Yes, the \scalebox command can be used with other TikZ commands to efficiently scale pictures. For example, you can use it to scale a node or a path. Just remember to enclose the content to be scaled in curly braces.

4. How do I adjust the scaling of a picture in TikZ?

You can adjust the scaling of a picture in TikZ by changing the scale factor in the \scalebox command. A scale factor of 1 will keep the picture at its original size, while a factor less than 1 will make it smaller and a factor greater than 1 will make it larger.

5. Is there a maximum or minimum scale factor in TikZ?

There is no maximum or minimum scale factor in TikZ. However, using extremely small or large scale factors may result in poor quality or distorted images. It is recommended to use scale factors between 0.5 and 2 for best results.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
697
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
937
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Back
Top