Graphics, Figures & Tablesplot curve

Information and discussion about graphics, figures & tables in LaTeX documents.
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

plot curve

Post by ditka »

Ok, I did not know that I shoud look at paterns, I only look at fill option.

As with the picture, I know I can plot polar plots, but the problam now is with coordinate axis. The best with that I can come is:(see atrachment)


So can I center the picture in coordinate system or is possibly to manipilate with default polar axis so that they will look like this?

Code: Select all

    \documentclass[11pt]{standalone}
    \usepackage[T1]{fontenc}
    \usepackage{pgfplots}
    \usepgfplotslibrary{polar}
    \usetikzlibrary{patterns}

    \begin{document}
      \begin{tikzpicture}[>=stealth]
   \draw[->] (-4,0) -- (4,0) node[right] {$x$};
    \draw[->] (0,-4) -- (0,4) node[above] {$y$};
        \begin{polaraxis}[hide axis]
          \addplot+[pattern=dots,pattern color=blue,mark=none,domain=0:360,samples=300]{cos(4*x)};
        \end{polaraxis}
      \end{tikzpicture}
    \end{document}
Attachments
dkslkdsl.JPG
dkslkdsl.JPG (19.17 KiB) Viewed 7358 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: plot curve

Post by cgnieder »

If you plot graphs with pgfplots then you also should plot the axes with pgfplots and not by drawing them with TikZ directly. Look at my previous post. There you should be able to see how can add the axes.

Regards
site moderator & package author
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

plot curve

Post by ditka »

Code: Select all

   \documentclass[11pt]{article}
    \usepackage[T1]{fontenc}
    \usepackage{pgfplots}
    \usepgfplotslibrary{polar}
    \usetikzlibrary{patterns}
    \begin{document}
    \begin{tikzpicture}
     \begin{polaraxis}[
       ticks=none,
       axis y line=center,
       axis x line=middle,
       axis on top,
       domain=0:2*pi]
         \addplot+[pattern=dots,pattern color=blue,mark=none,domain=0:360,samples=300]{cos(4*x)};
     \end{polaraxis}
    \end{tikzpicture}
    \end{document}
I know this is perhaps a little nonatural, but I woud like a cartesian coordinates for polar plots. Is that even possible?


And filling with points, I see now in manual, but what abaut filling with lines? Is that possible?(I gues it migt be done manualy, but since this is wery non practicaly, is there a better way to do it?
Attachments
dsdsdsdsd.JPG
dsdsdsdsd.JPG (19.51 KiB) Viewed 7346 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

plot curve

Post by localghost »

ditka wrote:[…] I know this is perhaps a little nonatural, but I woud like a cartesian coordinates for polar plots. Is that even possible? […]
In my opinion simply nonsense.
ditka wrote:[…] And filling with points, I see now in manual, but what abaut filling with lines? Is that possible?(I gues it migt be done manualy, but since this is wery non practicaly, is there a better way to do it?
Filling with lines is described in exactly the same section as the filling with dots. The patterns library has its own section which you can find by the ToC of the manual.
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

plot curve

Post by ditka »

localghost wrote:
ditka wrote:[…] I know this is perhaps a little nonatural, but I woud like a cartesian coordinates for polar plots. Is that even possible? […]
In my opinion simply nonsense.
ditka wrote:[…] And filling with points, I see now in manual, but what abaut filling with lines? Is that possible?(I gues it migt be done manualy, but since this is wery non practicaly, is there a better way to do it?
Filling with lines is described in exactly the same section as the filling with dots. The patterns library has its own section which you can find by the ToC of the manual.
I see the filing in tikz manual, I was looking in pgfplost before.

Abaut coordinate axis: I relly do not think this in nonsense. In the attacment there is example from Stewart calculus, where there is a simple coordinate system. So is it posible to do something like that?
Attachments
fkdkafakfkakf.JPG
fkdkafakfkakf.JPG (5.93 KiB) Viewed 7335 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

plot curve

Post by localghost »

OK. What you need is a parametrization (for all your plots you want to do like this). Then the coordinate system is indeed Cartesian. But this has few to do with polar plots.

Code: Select all

\documentclass[11pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}[>=stealth]
    \draw[blue] plot[parametric,samples=100,domain=0:6.2832] function {sin(t)*(1+cos(t)),cos(t)*(1+cos(t))};
    \draw[->] (-2.5,0) -- (2.5,0) node[right] {$x$};
    \draw[->] (0,-2.5) -- (0,2.5) node[above] {$y$};
  \end{tikzpicture}
\end{document}
It goes without saying that pgfplots simplifies such plots (but always draws or hides all axes, nothing in between).
Attachments
The resulting output.
The resulting output.
tikZ-cardioid.png (3.65 KiB) Viewed 7332 times
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

plot curve

Post by cgnieder »

pgfplots allows to to access the coordinate system of the axis that you're using, see section 4.16 of the manual.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}[>=stealth]
  \begin{polaraxis}[hide axis]
    \addplot+[pattern=dots,pattern color=blue,mark=none,domain=0:360,samples=300]{cos(4*x)};
    \draw[->] (axis cs:180,1.1) -- (axis cs:0,1.1) coordinate (x) ;
    \draw[->] (axis cs:-90,1.1) -- (axis cs:90,1.1) coordinate (y) ;
  \end{polaraxis}
  \node[right] at (x) {$x$};
  \node[above] at (y) {$y$};
\end{tikzpicture}

\end{document}
axiscs.png
axiscs.png (18.02 KiB) Viewed 7327 times
Regards
site moderator & package author
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Re: plot curve

Post by ditka »

Ok. Thank you both very much for your answers. This solve my plotting problems.
Post Reply