3

I'm reading the matplotlib docs. I'm struggling to find the keyword argument for the 'format string'. Or it is a positional arg only?

enter image description here

0

2 Answers 2

5

This is a specific pyplot argument (sort of a remnant of the older pylab). In 'ro', r means red, and 'o' means a round marker.

The arguments can be set like this instead:

color='r'
marker='.'
linestyle='-'  # if you need the dots connected by a line

Scroll down to see the matplotlib.pyplot.plot: Format Strings section. '[marker][line][color]'

plt.plot(range(1, 5), range(1, 17, 4), 'o-r')

# is equivalent to
plt.plot(range(1, 5), range(1, 17, 4), marker='o', linestyle='-', color='red')
Sign up to request clarification or add additional context in comments.

2 Comments

So if you want to use keyword arguments. The format string needs to be pulled apart and supplied as individual components?
Ok, ta. That's it!
1

Here is a proof from the matplotlib documentation that there is no such named argument - see "This argument cannot be passed as keyword.".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.