2

I want to create a stackplot using matplotlib. However, whatever I try I end up with ValueError: need at least one array to concatenate

Just to get started, the code I try to run is:

import matplotlib.pyplot as plt
plt.stackplot(x=range(4), y=[ [2,2,2,2], [1,2,3,4] ], labels=['a','b'])

Anyone has any ways to solve the problem?

1 Answer 1

2

Can you try the following

import matplotlib.pyplot as plt
plt.stackplot(range(4), [2, 2, 2, 2], [1, 2, 3, 4], labels=['a', 'b'])
plt.show()

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

I would recommend keeping the array as it is, plt.stackplot(range(4), [[2,2,2,2], [1,2,3,4]], labels=['a','b']). The main point is just that x and y are positional arguments, no keyword arguments.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.