Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsChoose a chart by the question you want it to answer: compare categories with bars, follow ordered change with a line, inspect a relationship with a scatter plot, or examine a numeric distribution with a histogram or box plot. The examples below use pandas plotting methods and one small DataFrame, so you can adapt them to your own columns.
Set up the examples
These examples use pandas to create and plot a DataFrame. If pandas is not installed, install it in your Python environment with python -m pip install pandas. The code also imports Matplotlib so you can display each plot.
import pandas as pd
import matplotlib.pyplot as plt
data = pd.DataFrame({
"month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
"sales": [120, 145, 138, 170, 190, 215],
"ad_spend": [20, 24, 22, 30, 32, 38],
"region": ["North", "South", "North", "South", "North", "South"]
})
The numbers are illustrative. For a plot, select the column or columns relevant to your question, label the axes, and call plt.show() to display the result in a script. In a notebook, plots may display automatically, but keeping the call makes the intended output clear.
1. How to make a bar chart in Python: compare categories
A bar chart is a good fit when the horizontal axis contains discrete labels and the task is to compare their values. It is particularly useful for labeled, non-time-series data. The following example compares sales by month; since the months are ordered, a line chart may be more appropriate if the main point is the trend.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
monthly_sales = data.set_index("month")["sales"]
ax = monthly_sales.plot.bar(color="steelblue")
ax.set_title("Sales by month")
ax.set_xlabel("Month")
ax.set_ylabel("Sales")
plt.tight_layout()
plt.show()
For long category names, a horizontal bar chart can be easier to read:
ax = monthly_sales.plot.barh(color="steelblue")
ax.set_title("Sales by month")
ax.set_xlabel("Sales")
ax.set_ylabel("Month")
plt.tight_layout()
plt.show()
2. How to plot a line graph in Python: show ordered change
Use a line when the x-axis has a meaningful order, such as time, and you want to follow the direction or continuity of change. Keep the values in the right order before plotting; a line connecting categories in an arbitrary order can imply a trend that is not there.
Rank #2
ax = data.plot.line(x="month", y="sales", marker="o")
ax.set_title("Sales over time")
ax.set_xlabel("Month")
ax.set_ylabel("Sales")
plt.tight_layout()
plt.show()
This uses month labels as an ordered sequence. With real dates, parse the date column and sort by it first so points are connected chronologically.
3. How to make a scatter plot in Python: inspect a relationship
A scatter plot places one numeric variable on each axis. It can help reveal a possible association, clusters, or unusual points; it does not by itself establish that one variable causes the other. Here, each point represents a month, with advertising spend on the x-axis and sales on the y-axis.
Rank #3
ax = data.plot.scatter(x="ad_spend", y="sales", color="darkorange")
ax.set_title("Sales and advertising spend")
ax.set_xlabel("Advertising spend")
ax.set_ylabel("Sales")
plt.tight_layout()
plt.show()
4. How to plot a histogram in Python: inspect a numeric distribution
A histogram groups numeric values into bins and shows the count in each bin. It is useful for seeing where observations concentrate and whether the distribution has a long tail or more than one apparent cluster. The choice of bin size affects the shape, so treat it as a view of the data rather than a definitive summary.
ax = data["sales"].plot.hist(bins=5, color="seagreen", edgecolor="white")
ax.set_title("Distribution of monthly sales")
ax.set_xlabel("Sales")
ax.set_ylabel("Count")
plt.tight_layout()
plt.show()
5. How to create a box plot in Python: compare distributions across groups
A box plot summarizes a numeric distribution by its quartiles and whiskers, and can make potential outliers visible. Use it to compare a numeric measure across categories when a compact summary matters more than displaying every observation. The pandas box plot below groups sales by region.
Rank #4
ax = data.boxplot(column="sales", by="region")
ax.set_title("Sales by region")
ax.set_xlabel("Region")
ax.set_ylabel("Sales")
plt.suptitle("")
plt.tight_layout()
plt.show()
Box plots compress the data: inspect the underlying observations as well if the individual values or sample sizes matter to your decision.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Which chart should you choose?
| Chart | Data shape | Best question | Useful when |
|---|---|---|---|
| Bar | Categories and a value for each | Which categories have larger or smaller values? | Comparing labeled groups; use horizontal bars when labels are long. |
| Line | Values in a meaningful order, often time | How does the measure change across the sequence? | Direction or continuity matters and observations can be connected sensibly. |
| Scatter | Two numeric variables per observation | Do the variables appear related, clustered, or unusual? | You want to inspect individual paired observations. |
| Histogram | One numeric variable | How are values distributed across a range? | You want counts by numeric interval rather than comparisons between groups. |
| Box plot | One numeric variable, optionally split by category | How do group distributions compare? | A compact distribution summary and potential outlier visibility are useful. |
pandas provides direct plotting methods for tabular data, including plot.bar(), plot.line(), plot.scatter(), plot.hist(), and plot.box(). For statistical relationships, distributions, and categorical plots beyond these quick examples, see Seaborn’s user guide. For lower-level customization and other plot types, browse the Matplotlib examples gallery. The pandas chart visualization guide documents its plotting methods and options.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

