ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Gavin via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Gavin <gavinpublic@comcast.net>
Subject: Re: tikzplot displacement result
Date: Sun, 12 Dec 2021 07:53:13 -0700	[thread overview]
Message-ID: <FA09EFCD-3D72-4AD3-A89E-4969914F2432@comcast.net> (raw)
In-Reply-To: <39B2FD7D-F620-406B-B701-F9E9DD0C9D7D@gmail.com>

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 <ntg-context@ntg.nl> 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
> ___________________________________________________________________________________

___________________________________________________________________________________
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
___________________________________________________________________________________

  reply	other threads:[~2021-12-12 14:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-12 10:13 Jan-Erik Hägglöf via ntg-context
2021-12-12 14:53 ` Gavin via ntg-context [this message]
2021-12-14 13:45   ` tikzplot displacement result [solved] Jan-Erik Hägglöf via ntg-context

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FA09EFCD-3D72-4AD3-A89E-4969914F2432@comcast.net \
    --to=ntg-context@ntg.nl \
    --cc=gavinpublic@comcast.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).