0

I am trying to create a scatter graph of following data

dict_a["src_ip"] =  This contains range of source IP all unique (192.168.x.x)
dict_a["src_port"] =  This contains range of source port all unique (1..100)
dict_a["time"] = This contains range of epoch time

I want to plot a graph with X axis having time, y axis having port and then plot the src_ip dots on the graph which will show that particular IP came tried connecting on this port on this time

I used something like this

plt.scatter(x=pkt_data['time'], y=pkt_data['src_port'])

Not sure how can i plot graph for the required information

I tried adding new code as below

    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)
    ax.scatter(time, port, alpha=0.8, c=z, edgecolors='none', s=30, label=ip)
    print(tuple(ip))
    plt.title('Matplot scatter plot')
    plt.legend(loc=5)
    plt.show()

I am getting graph as below enter image description here

Only problem is with the legend now. the color marker is coming in single line for all the IP's. Can i get this for every diff ip. z is just random number

Sumit
  • 1,953
  • 6
  • 32
  • 58
  • Does this answer your question? [Color by Column Values in Matplotlib](https://stackoverflow.com/questions/14885895/color-by-column-values-in-matplotlib) – Anwarvic Jun 01 '20 at 14:21
  • @Anwarvic: Unfortunately that does not answer my question – Sumit Jun 01 '20 at 15:52
  • Can you post an image with the expected result? Like you want to show 3 different of information on a 2D graph... how is that? yes, we can use color but as you can see `src_port` is 100 unique numbers... it isn't practical – Anwarvic Jun 01 '20 at 15:55
  • I cannot have image. Like X axis is time stamp, Y axis is port and IP is common to both port and time. – Sumit Jun 01 '20 at 16:02
  • @Anwarvic: I edited question. Please respond – Sumit Jun 01 '20 at 16:31
  • Could you add the value of `dict_a` to the question? If you read this data from a file, please upload it to a cloud-service like GoogleDrive and provide the link – Anwarvic Jun 02 '20 at 08:32

0 Answers0