0

I have a code where I have 5 ndarray and I need to visualize it on a matplotlib. To start with, I am just trying to plot only one ndarray like below:

x = data['embeddings'][0]
y = np.linspace(0, 50, 128)
plt.scatter(x, y)
plt.show()

It looks like something below:

enter image description here

Now the problem here is that if I plot other 4 ndarray's as well, this graph will look very messy and I will not be able check which ndarray is which one. So I was wondering if there is any way we can convert or map ndarray to int so that when we display it, there is only one point drawn on graph for one ndarray. Please suggest some good solution. Thanks

3
  • One trivial solution is assign color to each array. If that looks like too messy and crowded, maybe try to use pandas.DataFrame.sample on each array before you plot it. It would be important to know what do the values actually represent to give a better suggestion. Commented Apr 18, 2020 at 16:00
  • @PéterLeéh Can you give a very quick example Commented Apr 18, 2020 at 16:50
  • 1
    Try looking at the matplotlib gallery and elsewhere for different types of plots that might be helpful to you. We would need to know much more about your data than we do to answer this type of question without wild guesses. There might also be a way to reduce the dimensionality of your data (like what you might be suggesting by "converting to int"), but, again, we'd need to know more. Commented Apr 18, 2020 at 18:22

1 Answer 1

2

If you need to distinguish between the data drawn for all the nd array, you can use label alongwith legend.

x = data['embeddings'][0]
y = np.linspace(0, 50, 128)
plt.scatter(x, y, label="FirstGraph")

x2 = ....
y2= ....
plt.scatter(x2, y2, label="SecondGraph")
plt.legend() 
plt.show()

By this way, you will be able to distinguish the data drawn for different nd arrays.

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

1 Comment

Yes I think this can also help. Thanks

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.