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

  • Context: MHB 
  • Thread starter Thread starter karush
  • Start date Start date
  • Tags Tags
    Picture Scaling
Click For Summary
SUMMARY

The forum discussion focuses on efficiently scaling pictures in TikZ using the correct syntax. Users identified that the scale option must be included within the square brackets of the \begin{tikzpicture} command, specifically as [scale=0.8, declare function...]. This adjustment resolves issues with scaling not applying correctly. Additionally, participants expressed a desire to customize tick marks for critical points, highlighting limitations in tools like Desmos compared to TikZ.

PREREQUISITES
  • Familiarity with TikZ syntax and commands
  • Understanding of LaTeX document preparation
  • Knowledge of mathematical functions and plotting
  • Basic experience with coordinate systems in graphics
NEXT STEPS
  • Research TikZ advanced features for customizing plots
  • Explore LaTeX packages for enhanced graphics capabilities
  • Learn about the use of critical points in mathematical plotting
  • Investigate alternatives to Desmos for mathematical visualization
USEFUL FOR

Graphic designers, LaTeX users, mathematicians, and educators looking to enhance their skills in creating scalable and customizable graphics using TikZ.

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 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 0 ·
Replies
0
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
5
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K