2
$\begingroup$

I was viewing a video about the declination in fertility rates when I saw a good line chart. This is a multiple graphs line and each line have different form this can be useful for readers don't get confused comparing the lines because the colors is not enough for classify when you have various line.

enter image description here

This method could be useful when we have a up to +20 lines for plotting.

You don't need to answer about the specific tool of the graph above. only where I can do this? for example what theme of R, Python or Power Bi. I am able to do this for a line chart?

$\endgroup$
2
  • 1
    $\begingroup$ That plot was made with R package ggplot2. When making a plot, you can add a factor to change line type for each line. ggplot2.tidyverse.org/reference/aes_linetype_size_shape.html $\endgroup$
    – Mason
    Oct 3 at 3:32
  • $\begingroup$ This question feels weird to me, because AFAIK pretty much any software that can draw line graphs allows you to set both line style and color, including various kinds of dashed lines. Starting with Excel, LibreOffice, even the most basic graph tools. $\endgroup$
    – jpa
    Oct 3 at 13:23
2
$\begingroup$

The variations between lines in the image you have provided are usually set using color and line style properties in a programmatic plotting library (e.g. gnuplot, matplotlib in Python, etc).

Specifically how to control color and style varies from program to program, but an example showing a Matplotlib plot using the Seaborn styling package is similar to the image provided. In the code below for the Matplotlib library it uses the c parameter for setting the line color (documentation) and ls parameter for setting line style (documentation).

Example:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

th = np.linspace(0, 2*np.pi, 128)
sty='seaborn'

mpl.style.use(sty)
fig, ax = plt.subplots(figsize=(3, 3))

ax.set_title('style: {!r}'.format(sty), color='C0')
ax.plot(th, np.cos(th), 'C1', label='C1',c='r',ls='solid')
ax.plot(th, np.sin(th), 'C2', label='C2',c='b',ls=(0,(3,5,1,5)))
ax.legend()
fig.savefig('example.png')

Output Image:

example plot

$\endgroup$
1
$\begingroup$

You can also use plotly's for lines chart, which provide a more interactive feeling of your lines (e.g hovering over a line will display the values at this specific point). It is highly customizable so you can play around with it. In the documentation, there is an example specific to your case.

enter image description here

$\endgroup$
0
$\begingroup$

Checking Excel I see that I also can use Excel for change the shape of the lines pressing each line of the line chart and displaying the Format Data Series also there is a another option in case the double click doesn't work: right clicking in each line and go to the final Format Data Series.

enter image description here

enter image description here

There is a option ( do not confuse with the option above ) right clicking a line and Go to the Change Series Chart Type...

enter image description here

But In this case doesn't work for change the shape of each line only work for change the chart type of each column as you see.

$\endgroup$

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.