1

I'm trying to draw a quarter disc, I want to use the shade function to make it colorful, but what I get is just a little colorful arc, how can I color a quarter disc

\documentclass[border=30pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows.meta, calc, decorations.markings, quotes}
\begin{document}
\begin{tikzpicture}
\textcolor{purple}{
\draw[thick,->] (0,0) -- (2,0) node[anchor=north]{$X_0$};
\draw[thick,->] (0,0) -- (0,2) node[anchor=west]{$Y_0$};}
    \draw[pattern=dots](1,0,0) arc (0:90:1);
    \draw[thick, red] (0,0) -- ++({1*cos(30)},{1*sin(30)})node[midway, above]{$r$};
    \node[above=5pt, left=15pt] at (0,0){$O$};
\end{tikzpicture}
\end{document}
  • 1
    thank you i solve it, by this command: \fill[pattern=dots, pattern color=red ] (0,0) --(1,0,0) arc (0:90:1)--cycle; – moradov Mar 27 '18 at 10:51
3

It isn't obvious what you want to do with pattern, given that you say you want to use shading. Either way, the key is to specify a closed path around the area you want to fill.

Here, I leave pattern filling just the edge part and add a shading for the complete quarter disk. You should be able to modify if you desire a different combination.

\documentclass[border=30pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows.meta, calc, decorations.markings, quotes}
\begin{document}
\begin{tikzpicture}
  \draw[thick,->, purple] (0,0) -- (2,0) node[anchor=north]{$X_0$};
  \draw[thick,->, purple] (0,0) -- (0,2) node[anchor=west]{$Y_0$};
  \shade [bottom color=blue!50!cyan, top color=magenta, shading angle=-45, opacity=.25] (1,0,0) arc (0:90:1) -- (0,0,0) -- cycle;
  \draw[pattern=dots](1,0,0) arc (0:90:1);
  \draw[thick, red] (0,0) -- ++({1*cos(30)},{1*sin(30)})node[midway, above]{$r$};
  \node[above=5pt, left=15pt] at (0,0){$O$};
\end{tikzpicture}
\end{document}

shaded quarter

  • 2
    @Sebastiano I'm not sure what you mean. Merge the axis with what? You can put the radius r in the background by moving that line before the shading. Is that what you mean for that part? – cfr Mar 27 '18 at 11:07
  • 1
    @Sebastiano If the OP wants to merge the axes, they can be drawn as a single line. I think that the addition of a black dot at the origin would look a bit odd, since axes don't usually have such a feature. Whether the radius should be slightly shorter depends, I guess, on whether the outer border of the arc is considered part of the quarter or not. You might argue that it should be slightly longer, rather than slightly shorter, I guess. You could also draw the radius first and mark the arc second - then you wouldn't have to worry about adjustments for line width. Is that what you mean? – cfr Mar 27 '18 at 15:34
  • I delete my comments- – Sebastiano Mar 27 '18 at 19:26

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.