Graphics, Figures & TablesHow to include graphs with different colored lines

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
cantorj
Posts: 4
Joined: Thu Apr 27, 2023 5:33 pm

How to include graphs with different colored lines

Post by cantorj »

Hi,
I am relatively inexperienced with LaTex (I am using PcTex) and am writing a paper that has graphs with two different line colors, but includegraphics doesn't seem to support it. I have tried several different export formats: png, eps, etc. without success Thank you.

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
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

How to include graphs with different colored lines

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

\includegraphics supports colors. Perhaps post the exported image here as attachment (as pdf in the best case, or png; with eps I'm not sure about color conversion), and we can look at it.

Stefan
LaTeX.org admin
cantorj
Posts: 4
Joined: Thu Apr 27, 2023 5:33 pm

How to include graphs with different colored lines

Post by cantorj »

Stefan,
Thank you so much! Attached is a pdf example of what I am trying to include. Note that it was exported from RStudio.

Best,
Jim
Attachments
Rplot02.pdf
(10.96 KiB) Downloaded 129 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

How to include graphs with different colored lines

Post by Stefan Kottwitz »

Hi Jim,

I get two colors - try and click the "Run LaTeX here" button:

Code: Select all

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=\textwidth]{Rplot02.pdf}
\end{document}
What do you get?

Stefan
LaTeX.org admin
cantorj
Posts: 4
Joined: Thu Apr 27, 2023 5:33 pm

How to include graphs with different colored lines

Post by cantorj »

Stefan,
Thank you for your help. I think I may have sorted out the issue. For some reason, the DVI file only shows black and white, but curiously when I convert the DVI to pdf, the color is there. Attached are the examples. Have you run across this before? Any suggestion as to a fix? Thanks, again.

Best,
Jim
Attachments
FigTest.pdf
(25.4 KiB) Downloaded 131 times
DVI Screen Capture.png
DVI Screen Capture.png (24.87 KiB) Viewed 2073 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

How to include graphs with different colored lines

Post by Stefan Kottwitz »

Hi Jim,

DVI viewers are sometimes limited in capabilities, this may be a cause. Another possible cause may be that the coloring, in this case, uses a PDF feature which is not interpreted by the DVI viewer but survives converting to PDF.

I guess DVI will not be your final document format, so it's probably ok, just annoying in the preview.

Btw. I would use pgfplots for such jobs, see, for example, PGFplots.net. I just finished a plotting chapter of my upcoming TikZ book, I could send you a copy of that chapter if you like.

Stefan
LaTeX.org admin
cantorj
Posts: 4
Joined: Thu Apr 27, 2023 5:33 pm

How to include graphs with different colored lines

Post by cantorj »

Thank you, Stefan.
Right that I would use the pdf for printing and dissemination, but frustrating nonetheless. Yes, I would like to read your chapter on pgfplots as ultimately I would like nicer looking graphs. I truly appreciate your help.

Best,
Jim
Post Reply