TransWikia.com

How do I make a labelled line chart?

Data Science Asked by nozo on April 29, 2021

suppose I want to track the ratings of seasons of a TV show. so there are three columns of data-season number, year, and ratings. I want the year and ratings on the axes and season number as labels on the points. how can this be achieved considering visualization tools only take in values for X and Y axes?

2 Answers

Have a look at matplotlib's annotate.

Here are some examples. I believe it works well with seaborn too.

Answered by Paul92 on April 29, 2021

I am assuming the tv show ratings of a season changes as time passes. If you are using a library called Pandas there is a function called groupby, which helps you to group certain columns of a dataframe and form a new dataframe.

To import pandas

import pandas as pd

Groupby syntax

New_dataframe=old.groupby("Year")["Season Number"].function_you_want_to_use()
New_dataframe.plot(kind="bar",stacked="True")

If stacked is true the bars will will be on top of one another.

This image is just an example from another dataset

I don't have your exact data. So consider
the x axis as year
the y axis as ratings
labels as season number(example S1-blue, S2-orange, S3-green)

Answered by Shiv on April 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP