HI! I’m trying to fit the funktion in the right place in this plot but it seems to get displaced. What is wrong with the code? Is there a way to do this in Metafun? Thanks in advance Sincerely Jan-Erik \setupbodyfont[10pt] \enableregime[utf] \usemodule[tikz] \usemodule[pgfplots] \usetikzlibrary[arrows] \setuppagenumbering[location=] \starttext \definecolor[ffvvqq][r=1.,g=0.3333333333333333,b=0.] \startTEXpage \starttikzpicture[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \startaxis [ x=1.0cm,y=1.0cm, axis lines=middle, ymajorgrids=true, xmajorgrids=true, xmin=-3.2488079448294145, xmax=34.87398305791419, ymin=-7.496155590728956, ymax=11.53265632858922, xtick={-3.0,-2.0,...,34.0}, ytick={-7.0,-6.0,...,11.0},] \clip(-3.2488079448294145,-7.496155590728956) rectangle (34.87398305791419,11.53265632858922); \draw[line width=2.pt,color=ffvvqq,smooth,samples=100,domain=-3.2488079448294145:34.87398305791419] plot(\x,{(\x)+3}); \draw[color=ffvvqq] (-3.5583519743388714,-0.7831230981304516) node {$h$}; \stopaxis \stoptikzpicture \stopTEXpage \stoptext
Hi Jan-Erik, Use the \addplot command when you use pgfplots. The manual, pgfplots.pdf, is quite good. \setupbodyfont[10pt] \enableregime[utf] \usemodule[tikz] \usemodule[pgfplots] \usetikzlibrary[arrows] \setuppagenumbering[location=] \starttext \definecolor[ffvvqq][r=1.,g=0.3333333333333333,b=0.] \startTEXpage \starttikzpicture[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \startaxis [ x=1.0cm,y=1.0cm, axis lines=middle, ymajorgrids=true, xmajorgrids=true, xmin=-3.2488079448294145, xmax=34.87398305791419, ymin=-7.496155590728956, ymax=11.53265632858922, xtick={-3.0,-2.0,...,34.0}, ytick={-7.0,-6.0,...,11.0},] %\clip(-3.2488079448294145,-7.496155590728956) rectangle (34.87398305791419,11.53265632858922); \addplot[line width=2.pt,color=ffvvqq,smooth,samples=100,domain=-3.2488079448294145:34.87398305791419]{x+3} node[below right, pos= 0.1]{$h$}; \stopaxis \stoptikzpicture \stopTEXpage \stoptext I removed the clip command because it is causing a problem and is unnecessary. I don’t know what you are trying to do with the node{$h$}, but I made it a label on the plot. The metafun graph module would also work for this plot, but it pgfplots is more mature. I recommend using pgfplots unless you are already skilled with metapost. Hope that gets you going in the right direction. Gavin
On Dec 12, 2021, at 3:13 AM, Jan-Erik Hägglöf via ntg-context
wrote: HI!
I’m trying to fit the funktion in the right place in this plot but it seems to get displaced.
What is wrong with the code?
Is there a way to do this in Metafun?
Thanks in advance
Sincerely
Jan-Erik
\setupbodyfont[10pt] \enableregime[utf] \usemodule[tikz] \usemodule[pgfplots] \usetikzlibrary[arrows] \setuppagenumbering[location=] \starttext \definecolor[ffvvqq][r=1.,g=0.3333333333333333,b=0.] \startTEXpage \starttikzpicture[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \startaxis [ x=1.0cm,y=1.0cm, axis lines=middle, ymajorgrids=true, xmajorgrids=true, xmin=-3.2488079448294145, xmax=34.87398305791419, ymin=-7.496155590728956, ymax=11.53265632858922, xtick={-3.0,-2.0,...,34.0}, ytick={-7.0,-6.0,...,11.0},] \clip(-3.2488079448294145,-7.496155590728956) rectangle (34.87398305791419,11.53265632858922); \draw[line width=2.pt,color=ffvvqq,smooth,samples=100,domain=-3.2488079448294145:34.87398305791419] plot(\x,{(\x)+3}); \draw[color=ffvvqq] (-3.5583519743388714,-0.7831230981304516) node {$h$}; \stopaxis \stoptikzpicture \stopTEXpage \stoptext ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
HI! Thank you for your help. The code was generated by Geogebra Classic 5 "export to pgf/tikz" function and it seems to have errors that needs to be solved in that application. Now I have a good template to do this on my own. Regards Jan-Erik
12 dec. 2021 kl. 15:53 skrev Gavin
: Hi Jan-Erik,
Use the \addplot command when you use pgfplots. The manual, pgfplots.pdf, is quite good.
\setupbodyfont[10pt] \enableregime[utf] \usemodule[tikz] \usemodule[pgfplots] \usetikzlibrary[arrows] \setuppagenumbering[location=] \starttext \definecolor[ffvvqq][r=1.,g=0.3333333333333333,b=0.] \startTEXpage \starttikzpicture[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \startaxis [ x=1.0cm,y=1.0cm, axis lines=middle, ymajorgrids=true, xmajorgrids=true, xmin=-3.2488079448294145, xmax=34.87398305791419, ymin=-7.496155590728956, ymax=11.53265632858922, xtick={-3.0,-2.0,...,34.0}, ytick={-7.0,-6.0,...,11.0},] %\clip(-3.2488079448294145,-7.496155590728956) rectangle (34.87398305791419,11.53265632858922); \addplot[line width=2.pt,color=ffvvqq,smooth,samples=100,domain=-3.2488079448294145:34.87398305791419]{x+3} node[below right, pos= 0.1]{$h$}; \stopaxis \stoptikzpicture \stopTEXpage \stoptext
I removed the clip command because it is causing a problem and is unnecessary. I don’t know what you are trying to do with the node{$h$}, but I made it a label on the plot.
The metafun graph module would also work for this plot, but it pgfplots is more mature. I recommend using pgfplots unless you are already skilled with metapost.
Hope that gets you going in the right direction.
Gavin
On Dec 12, 2021, at 3:13 AM, Jan-Erik Hägglöf via ntg-context
wrote: HI!
I’m trying to fit the funktion in the right place in this plot but it seems to get displaced.
What is wrong with the code?
Is there a way to do this in Metafun?
Thanks in advance
Sincerely
Jan-Erik
\setupbodyfont[10pt] \enableregime[utf] \usemodule[tikz] \usemodule[pgfplots] \usetikzlibrary[arrows] \setuppagenumbering[location=] \starttext \definecolor[ffvvqq][r=1.,g=0.3333333333333333,b=0.] \startTEXpage \starttikzpicture[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \startaxis [ x=1.0cm,y=1.0cm, axis lines=middle, ymajorgrids=true, xmajorgrids=true, xmin=-3.2488079448294145, xmax=34.87398305791419, ymin=-7.496155590728956, ymax=11.53265632858922, xtick={-3.0,-2.0,...,34.0}, ytick={-7.0,-6.0,...,11.0},] \clip(-3.2488079448294145,-7.496155590728956) rectangle (34.87398305791419,11.53265632858922); \draw[line width=2.pt,color=ffvvqq,smooth,samples=100,domain=-3.2488079448294145:34.87398305791419] plot(\x,{(\x)+3}); \draw[color=ffvvqq] (-3.5583519743388714,-0.7831230981304516) node {$h$}; \stopaxis \stoptikzpicture \stopTEXpage \stoptext ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
participants (2)
-
Gavin
-
Jan-Erik Hägglöf