Graphics, Figures & Tables ⇒ line changing color latex tikz
-
- Posts: 4
- Joined: Fri Mar 06, 2015 11:10 pm
line changing color latex tikz
So I'm drawing a picture in tikz and when I use the \shade command my lines are changing from black into the color I'm shading with. Does anyone know how to prevent this?
Thanks so much!
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: line changing color latex tikz
can you show us a small but compilable example so we know what you are doing? Just like a picture, a compilable example is worth a thousand words. And it saves time for helpers.
-
- Posts: 4
- Joined: Fri Mar 06, 2015 11:10 pm
line changing color latex tikz
Code: Select all
%------------------------------------------------------------
%
\documentclass{article}
%
%----------------------------------------------------------
%
\usepackage{amsmath}%
\usepackage{bm}%
\usepackage{mathtools}%
\usepackage{amsfonts}%
\usepackage{amssymb}%
\usepackage{amsthm}%
\usepackage{mathrsfs}%
\usepackage{graphicx}%
\usepackage{float}%
\usepackage{cases}%
\usepackage{tikz}%
\usepackage{epigraph}%
\usepackage{verbatim}%
\usepackage{setspace}
%
%
%------------------------------------------------------------
% Theorem like environments
%
\tikzset{>=latex}
---------
%
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\draw[thick,black,-] (0,0) to (5.5,0);
\draw[thick,->] (6.65,0) to (10,0);
\node[right] at (10,0) {$z$};
\draw[semithick] (5,-1.5) arc (270:90:0.5 and 1.5);% left half of the inner ellipse
\draw[semithick] (5,-1.5) arc (-90:90:0.5 and 1.5);% right half of the inner ellipse
\shade[left color=blue!5!white,right color=blue!60!white,opacity=0.7] (5,-1.5) arc (270:90:0.5 and 1.5) -- (5,-1.5) arc (-90:90:0.5 and 1.5) -- cycle; %inside cylinder
\end{tikzpicture}
\caption{Control volume approach for energy balance.}
\label{overflow}
\end{figure}
\end{document}
line changing color latex tikz


The shade command uses the same color unless you specify a different color by way of draw parameter. Look at the code below to see the difference:
Code: Select all
\documentclass{standalone}
%
\usepackage{tikz}%
%
\tikzset{>=latex}
%
\begin{document}
\begin{tikzpicture}
\shade[left color=blue!5!white, right color=blue!60!white,
opacity=0.7]
(5,-1.5) arc (270:90:0.5 and 1.5) -- (5,-1.5)
arc (-90:90:0.5 and 1.5) -- cycle;
\begin{scope}[xshift=3cm]
\shade[left color=blue!5!white, right color=blue!60!white,
opacity=0.7, draw=black]
(5,-1.5) arc (270:90:0.5 and 1.5) -- (5,-1.5)
arc (-90:90:0.5 and 1.5) -- cycle;
\end{scope}
\end{tikzpicture}
[attachment=0]x.png[/attachment]
\end{document}
- Attachments
-
- x.png (8.02 KiB) Viewed 29866 times
OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
-
- Posts: 4
- Joined: Fri Mar 06, 2015 11:10 pm
Re: line changing color latex tikz
But it seems that using the "draw=black" command puts a black border around the shaded region. This is adding areas of black where I was trying to avoid (since some shaded areas were not suppose to have lines through them) and not darkening other lines passing through the shade region (it shades those lines). Any idea how to proceed?
line changing color latex tikz
When you are in the editing box, click on thejoshmccraney wrote:What do you mean by "code tags"? And thanks so much for helping!
Code: Select all
button at the top and paste your code snippet netween the [code]
Try draw=none. Does that help? Are you trying to draw a cylinder?But it seems that using the "draw=black" command puts a black border around the shaded region.
OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim