python code to create scatter plot of the data given in the screenshot. Plot a scatterplot using python of lung cancer deaths against cigarettes sales, using the two letter abbreviation for each US state as the marker.
python code to create scatter plot of the data given in the screenshot.
Plot a scatterplot using python of lung cancer deaths against cigarettes sales, using the two letter abbreviation for each US state as the marker.
Creating a scatter plot to visualize the relationship between cigarette sales and lung cancer deaths across different U.S. states can be a useful way to identify trends or patterns in the data. This kind of visualization can serve various purposes: from healthcare policy planning to public awareness programs. Python's matplotlib library provides the necessary tools to create such a scatter plot easily.
Algorithm
Data Preparation: Load the data, which is represented as a list of dictionaries. Each dictionary contains information about a U.S. state, such as its abbreviation, cigarette sales, and lung cancer deaths.
Data Extraction: Separate the data into distinct lists for state abbreviations, cigarette sales, and lung cancer deaths.
Plot Initialization: Initialize a new scatter plot using matplotlib.
Data Plotting: Plot the extracted cigarette sales and lung cancer deaths data points on the scatter plot.
Annotation: Annotate each data point with the corresponding state's two-letter abbreviation.
Axis Labeling and Titling: Label the x-axis and y-axis and provide a title for the scatter plot.
Display Plot: Finally, display the plot for visual analysis.
The list of first 10 rows data has been given in the code. To produce the full chart, you just need to add other row's data
Step by step
Solved in 5 steps with 1 images