1

enter image description here

Question: Once you compile my codes, you will find the output like above pic. My question is whatever I made change manually with red color, How can I achieve that? Second question how to remove ticks from both axis and label both axis as X-axis and Y-axis.

Thanks

MWE:

\documentclass[12pt]{article}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\usepgfplotslibrary{fillbetween}
\pagestyle{empty}
\usetikzlibrary{arrows,decorations.markings}
\begin{document}
\begin{center}
    \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\begin{axis}[
x=1cm,y=1cm,
axis lines=middle,
axis line style={stealth-stealth},
xmin=-7,
xmax=7,
ymin=-3,
ymax=7,
xticklabels=empty,
yticklabels=empty]
\draw [fill=black] (0,0) circle (3.5pt);
\node [black] at (1,1) {$\circ$};
\node [black] at (2,1) {$\circ$};
\node [black] at (3,1) {$\circ$};
\node [black] at (4,1) {$\circ$};
\node [black] at (5,1) {$\circ$};
\node [black] at (1,2) {$\circ$};
\node [black] at (2,2) {$\circ$};
\node [black] at (3,2) {$\circ$};
\node [black] at (4,2) {$\circ$};
\node [black] at (5,2) {$\circ$};
\node [black] at (1,3) {$\circ$};
\node [black] at (2,3) {$\circ$};
\node [black] at (3,3) {$\circ$};
\node [black] at (4,3) {$\circ$};
\node [black] at (5,3) {$\circ$};
\node [black] at (-1,1) {$\circ$};
\node [black] at (-2,1) {$\circ$};
\node [black] at (-3,1) {$\circ$};
\node [black] at (-4,1) {$\circ$};
\node [black] at (-5,1) {$\circ$};
\node [black] at (-1,2) {$\circ$};
\node [black] at (-2,2) {$\circ$};
\node [black] at (-3,2) {$\circ$};
\node [black] at (-4,2) {$\circ$};
\node [black] at (-5,2) {$\circ$};
\node [black] at (-1,3) {$\circ$};
\node [black] at (-2,3) {$\circ$};
\node [black] at (-3,3) {$\circ$};
\node [black] at (-4,3) {$\circ$};
\node [black] at (-5,3) {$\circ$};
\draw [decoration={markings,mark=at position 1 with
    {\arrow[scale=2,>=stealth]{>}}},postaction={decorate}] (-1,-2) -- (-1,-1);
    \draw [decoration={markings,mark=at position 1 with
    {\arrow[scale=2,>=stealth]{>}}},postaction={decorate}] (-2,-2) -- (-2,-1);
    \draw [decoration={markings,mark=at position 1 with
    {\arrow[scale=2,>=stealth]{>}}},postaction={decorate}] (-3,-2) -- (-3,-1);
    \draw [decoration={markings,mark=at position 1 with
    {\arrow[scale=2,>=stealth]{>}}},postaction={decorate}] (1,-2) -- (1,-1);
    \draw [decoration={markings,mark=at position 1 with
    {\arrow[scale=2,>=stealth]{>}}},postaction={decorate}] (2,-2) -- (2,-1);
    \draw [decoration={markings,mark=at position 1 with
    {\arrow[scale=2,>=stealth]{>}}},postaction={decorate}] (3,-2) -- (3,-1);
\draw[color=black] (2.0,-3) node[left,above] {$B_{0}$};
\draw[color=black] (-2.0,-3) node[left,above] {$B_{0}$};
\draw[color=black] (-5.5,-2) node[left,above] {$T_{w}$};
\draw[color=black] (-4.5,-2) node[left,above] {$C_{w}$};
\draw[color=black] (5.5,-2) node[left,above] {$C_{w}$};
\draw[color=black] (4.5,-2) node[left,above] {$T_{w}$};
\draw[color=black] (-5.5,6) node[left,above] {$T_{\infty}$};
\draw[color=black] (-4.5,6) node[left,above] {$C_{\infty}$};
\draw[color=black] (5.5,6) node[left,above] {$T_{\infty}$};
\draw[color=black] (4.5,6) node[left,above] {$C_{\infty}$};
\draw[color=black] (2.8,4) node[left,above] {$u_{e}(x)$};
\draw[color=black] (-2.8,4) node[left,above] {$u_{e}(x)$};
%%%%%%%%%%%%%%%%%%%%%%%%curve%%%%%%%%%%%%%%%%%%%%%%%%
\draw (axis cs:1.0,7.0) to [bend right=35] coordinate[pos=0.2] (l_i) (axis cs:7,1.0);
\draw (axis cs:0.7,7.0) to [bend right=35] coordinate[pos=0.2] (l_i) (axis cs:5,1.0);
\draw (axis cs:0.5,7.0) to [bend right=35] coordinate[pos=0.2] (l_i) (axis cs:3,1.0);
\draw (axis cs:-1.0,7.0) to [bend left=35] coordinate[pos=0.2] (l_i) (axis cs:-7,1.0);
\draw (axis cs:-0.7,7.0) to [bend left=35] coordinate[pos=0.2] (l_i) (axis cs:-5,1.0);
\draw (axis cs:-0.5,7.0) to [bend left=35] coordinate[pos=0.2] (l_i) (axis cs:-3,1.0);
%%%%%%%%%%%%%%%%%%Rectangle%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\filldraw[fill=blue!20!white, draw=black] (-6,0) -- (-6,-0.1) -- (6,-0.1) -- (6,0) -- (-6,0);
\draw[color=black] (1.8,0.2) node [right,above,rotate=00]{Stagnation Point};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
2
  • 1
    What is the reason for using \draw[color=black] (2.0,-3) node[left,above] {$B_{0}$};? With this you draw nothing. Why not just place a node directy with \node[left,above] at (2.0,-3) {$B_{0}$}; or even \node at (2.0,-3) {$B_{0}$}; ? Aug 10 at 11:54
  • Why not use instead of numerous \node commands something like \foreach \x in {1,...,5} \foreach \y in {1,...,3}{ \edef\temp{\noexpand\node [black] at (\x,\y) {$\circ$};}\temp \edef\temp{\noexpand\node [black] at (-\x,\y) {$\circ$};}\temp }
    – kabenyuk
    Aug 10 at 12:25

1 Answer 1

2

The tick mark lines can be removes by adding the option tick style={draw=none} to the axis environment.

However, instead of trying to delete the tick marks from the axes, you should probably just draw them using regular TikZ macros, since you don't use the functionality of PGFplots anyways. Even the bent lines are essentially drawn and not plotted into the axis scope. Apart from that, your code can be simplified in a lot of ways:

  • Use plain \node at (2.0,-2.5) {$B_{0}$}; instead of \draw[color=black] (2.0,-3) node[left,above] {$B_{0}$};. (You only need to adjust the y coordinate a bit.)
  • Use a foreach loop to draw the small circles and draw them using a circle node shape. You could also draw circles directly.
  • You can use another foreach loop to draw the arrows pointing upwards. You could probably use even more loops, but this might render the code less readable.
  • Do not use decorations to attach arrow tips at the end of straight lines. Just use the option -> instead.
  • Don't use the deprecated arrows library, but use the modern arrows.meta library instead. Define the arrow tip at the tikzpicture level once, then refer to it using just > (or <).
  • Draw the circle for the stagnation point last in order to make it overlap the other things.
  • Do not create multiple identically named coordinates on different paths which you do not use anyways.
  • Use cycle to properly close paths.
  • Overall, remove unused or redundant styles. For example x=1cm, y=1cm is the default setting, so there is no reason to add this. Also, \draw already draws something in black and \fill already fills something in black. So, there is no need to add the option black to these macros.

Sorry for rewriting your code that much, since this is not what you asked for. I still hope that it can help you! (In the end, the answer to your question is also included here.)

Taken everything together, I would probably do the following:

\documentclass[border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows.meta, bending, decorations.markings}

\begin{document}
\begin{tikzpicture}[line cap=round, >={Stealth[length=7pt]}]
\draw[<->] (0,-3) -- (0,7);
\draw[<->] (-7,0) -- (7,0);
\foreach \x in {-5,...,-1,1,2,...,5} {
    \foreach \y in {1,2,3} {
        \node[circle, draw, inner sep=1.5pt] at (\x,\y) {};
    }
}
\foreach \x in {-1,-2,-3,1,2,3} {
    \draw[->] (\x,-2) -- (\x,-1);
}
\node at (2.0,-2.5) {$B_{0}$};
\node at (-2.0,-2.5) {$B_{0}$};
\node at (-5.5,-1.5) {$T_{w}$};
\node at (-4.5,-1.5) {$C_{w}$};
\node at (5.5,-1.5) {$C_{w}$};
\node at (4.5,-1.5) {$T_{w}$};
\node at (-5.5,6.5) {$T_{\infty}$};
\node at (-4.5,6.5) {$C_{\infty}$};
\node at (5.5,6.5) {$T_{\infty}$};
\node at (4.5,6.5) {$C_{\infty}$};
\node at (2.8,4.5) {$u_{e}(x)$};
\node at (-2.8,4.5) {$u_{e}(x)$};
%%%%%%%%%%%%%%%%%%%%%%%%curve%%%%%%%%%%%%%%%%%%%%%%%%
\draw[decoration={markings, mark=at position .4 with {\arrow{[red]>[bend]}}}, postaction={decorate}] (1.0,7.0) to [bend right=35] (7,1.0);
\draw (0.7,7.0) to [bend right=35] (5,1.0);
\draw (0.5,7.0) to [bend right=35] (3,1.0);
\draw[decoration={markings, mark=at position .4 with {\arrow{[red]>[bend]}}}, postaction={decorate}] (-1.0,7.0) to [bend left=35] (-7,1.0);
\draw (-0.7,7.0) to [bend left=35] (-5,1.0);
\draw (-0.5,7.0) to [bend left=35] (-3,1.0);
%%%%%%%%%%%%%%%%%%Rectangle%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\draw[fill=blue!20!white] (-6,0) -- (-6,-0.1) -- (6,-0.1) -- (6,0) -- cycle;     % or: \draw[fill=blue!20!white] (-6,0) rectangle (6,-0.1); 
\filldraw[red] (0,0) circle (3.5pt);
\draw[{<[bend]}-, red, shorten <=5pt] (0,0) to[bend left] (.5,.5) node[right] {Stagnation Point};
\end{tikzpicture}
\end{document}

enter image description here

4
  • Is it possible to move red bend arrow to right side of the y-axis ?
    – Math-Man
    Aug 10 at 13:17
  • @Math-Man So, you want this arrow to point from the label to the node? Aug 10 at 13:18
  • And Thanks for replying it's probably fulfill my requirement.
    – Math-Man
    Aug 10 at 13:18
  • @Math-Man I changed the code a little bit, so the arrow now points from the label to the node. Aug 10 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.