'How do you make an errorbar plot in matplotlib using linestyle=None in rcParams?

When plotting errorbar plots, matplotlib is not following the rcParams of no linestyle. Instead, it's plotting all of the points connected with a line. Here's a minimum working example:

import matplotlib.pyplot as plt

lines = {'linestyle': 'None'}
plt.rc('lines', **lines)

plt.errorbar((0, 1), (1, 0), yerr=(0.1, 0.1), marker='o')

plt.savefig('test.pdf')
plt.delaxes()

enter image description here

Is the only solution to explicitly set linestyle='None' when calling pyplot.errorbar()?



Solution 1:[1]

Using: fmt='' indeed doesn't work. One needs to put something that is not an empty string. As mentioned by @strpeter, a dot or any other marker would work. Examples: fmt='.' fmt=' ' fmt='o'

Solution 2:[2]

Or use an empty linestyle:

plt.errorbar(x, y, yerr=.1, fmt=None, color='b', linestyle='')

This works for me in matplotlib version 3.3.3

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dana Toker Nadler
Solution 2 Caroline