- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to modify a 2d Scatterplot to display color based on a third array in a CSV file?
63 Lectures 6 hours
To modify a 2d scatterplot to display color based on a third array in a CSV file, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Read the CSV file with three headers.
- Create a new figure or activate an existing figure.
- Add an 'ax' to the figure as part of a subplot arrangement.
- Make a scatter plot with CSV file data points.
- To display the figure, use show() method.
import pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True columns = ["data1", "data2", "data3"] df = pd.read_csv("input.csv", usecols=columns) fig = plt.figure() ax = fig.add_subplot(111) ax.scatter(df.data1, df.data2, df.data3, marker="*") plt.show()
The "input.csv" file contains the following data
When we run the code, it will produce the following scatter plot
- How to color scatterplot points based on a threshold using ggplot2 in R?
- How to read a 2d array from a file in java?
- How to create a scatterplot using ggplot2 with different shape and color of points based on a variable in R?
- How to color a Matplotlib scatterplot using a continuous value?
- How to parse a CSV file using PHP
- How to save a Python Dictionary to CSV file?
- How to output MySQL query results in CSV format and display it on the screen, not a file?
- How to create a CSV file manually in PowerShell?
- How to create a blank csv file in R?
- Writing a Pandas DataFrame to CSV file
- How to store a 2d Array in another 2d Array in java?
- Python - How to write pandas dataframe to a CSV file
- How to find and modify a value in a nested array?