Graphics, Figures & Tablesline changing color latex tikz

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
joshmccraney
Posts: 4
Joined: Fri Mar 06, 2015 11:10 pm

line changing color latex tikz

Post by joshmccraney »

hi latex community!

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!

Recommended reading 2024:

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

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

Post by Johannes_B »

Hi and welcome,

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.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
joshmccraney
Posts: 4
Joined: Fri Mar 06, 2015 11:10 pm

line changing color latex tikz

Post by joshmccraney »

Hi! Thanks for the welcome. Below is what I think you're asking for. Let me know if it's something different and I'll do my best to attach what you need. Thanks so much for helping!

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}
Last edited by Stefan Kottwitz on Sat Mar 07, 2015 10:59 am, edited 1 time in total.
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

line changing color latex tikz

Post by mas »

You should remove all the unwanted stuff from the code and post a really minimum example (Infominimal working example). Also, you should use the code tags to input you code :-)

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}
The output is as below:
Attachments
x.png
x.png (8.02 KiB) Viewed 29875 times

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
joshmccraney
Posts: 4
Joined: Fri Mar 06, 2015 11:10 pm

Re: line changing color latex tikz

Post by joshmccraney »

Sorry about not making it minimum! I'll work on doing a better job. What do you mean by "code tags"? And thanks so much for helping!

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?
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

line changing color latex tikz

Post by mas »

joshmccraney wrote:What do you mean by "code tags"? And thanks so much for helping!
When you are in the editing box, click on the

Code: Select all

 button at the top and paste your code snippet netween the [code]
tags.
But it seems that using the "draw=black" command puts a black border around the shaded region.
Try draw=none. Does that help? Are you trying to draw a cylinder?

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
Post Reply