Tajamul Khan
@Tajamulkhann
[Link](x, y): Line plot for trends and
continuous data.
[Link](x, y): Visualize
relationships between two variables
using scatter plots.
[Link](x, height): Bar chart to
compare categorical data.
[Link](y, width): Horizontal bar
chart for easier comparison.
[Link](data, bins=10): Histogram to
analyze data distribution.
[Link](sizes, labels=labels): Show
proportions of categories using a pie
chart.
[Link](data): Summarize
distributions and detect outliers.
[Link](data): Show density
and distribution of data.
@Tajamulkhann
[Link]('Title'): Set the title of the
plot.
[Link]('X Label'): Set the label for
the x-axis.
[Link]('Y Label'): Set the label for
the y-axis.
[Link](): Display the legend for
the plot.
[Link](True): Enable gridlines on
the plot.
[Link]([xmin, xmax]): Set the x-
axis limits.
[Link]([ymin, ymax]): Set the y-
axis limits.
[Link](rotation=45): Rotate the
x-axis labels for better readability.
@Tajamulkhann
[Link](nrows, ncols, index):
Create a subplot in a grid.
plt.subplots_adjust(left, right, top,
bottom): Adjust subplot spacing.
fig, ax = [Link](): Create a
figure and axes object for finer
control.
fig.tight_layout(): Automatically
adjust subplot parameters to fit the
figure area.
[Link](121): Create a subplot in
a 1x2 grid (first position).
[Link](2, 2): Create a 2x2 grid
of subplots.
[Link](x, y): Use ax (axes) to plot
directly into a specific subplot.
ax.set_title('Subplot Title'): Set a
title for a specific subplot.
@Tajamulkhann
[Link]('ggplot'): Apply a
specific style to the plot (e.g.,
'ggplot', 'seaborn').
[Link](x, y, 'ro'): Customize the plot
style and markers (red circles).
[Link](x, y, linestyle='--', color='g'):
Set the line style and color (green
dashed line).
[Link](x, y, c='blue', marker='x'):
Set color & marker for scatter plot.
[Link](x, height, color='skyblue'):
Customize bar chart colors.
[Link](data, bins=9, color='purple'):
Set color for histogram bars.
[Link](x, y, alpha=0.5): Adjust
transparency of plot elements.
[Link](sizes, colors=['red', 'green',
'blue']): Set specific colors for pie
chart sections.
@Tajamulkhann
[Link]('Text', xy=(x, y), xytext=
(xtext, ytext), arrowprops=
dict(arrowstyle="->")): Annotate the
plot with text and optional arrows.
[Link](x, y, 'Text'): Place text at
specified coordinates on the plot.
[Link]('Title', fontsize=14): Set title
with customized font size.
[Link]('X Label', fontsize=12): Set
x-axis label with font size.
[Link]('Y Label', fontsize=12): Set
y-axis label with font size.
[Link]([0, 1, 2], ['A', 'B', 'C']):
Change x-tick labels to custom values.
[Link]([10, 30], ['Low', 'High']):
Customize y-tick labels.
[Link](2, 3, 'Annotation'): Add simple
annotation text at specific
coordinates.
@Tajamulkhann
[Link]('[Link]'): Save the
current plot as a PNG file.
[Link]('[Link]', dpi=300): Save
plot as a PDF with specified resolution.
[Link]('[Link]'): Save plot as an
SVG file for scalable graphics.
[Link]('[Link]',
transparent=True): Save plot with
transparent background.
[Link]('[Link]'): Save a
specific figure object to a file.
[Link]('[Link]',
bbox_inches='tight'): Save plot with
tight bounding box (no extra space).
[Link]('[Link]', pad_inches=1):
Control padding around saved figure.
[Link]('[Link]', dpi=300,
quality=95): Save with custom quality
and resolution.
@Tajamulkhann
from mpl_toolkits.mplot3d import
Axes3D: Import 3D plotting toolkit.
fig = [Link](): Create a figure
object for 3D plotting.
ax = fig.add_subplot(111,
projection='3d'): Create 3D axes.
ax.plot3D(x, y, z): Plot a 3D line graph.
ax.scatter3D(x, y, z): Create a 3D
scatter plot.
ax.plot_surface(x, y, z, cmap='viridis'):
Create a 3D surface plot with color
map.
ax.contour3D(x, y, z, 50): Create 3D
contour plot.
ax.bar3d(x, y, z, dx, dy, dz): Create a
3D bar plot.
@Tajamulkhann
[Link](x, y): Create a basic plot.
[Link](1, 2, 1): Create subplots in
a single row, first plot.
[Link](1, 2, 2): Create subplots in
a single row, second plot.
[Link](2, 2): Create a 2x2 grid
of subplots.
[Link](x, y), [Link](x, z): Plot on
different axes in subplots.
fig.tight_layout(): Adjust layout of
multiple subplots automatically.
plt.subplots_adjust(left, right, top,
bottom): Customize the spacing
between subplots.
[Link](111): Create a single full-
sized plot.
@Tajamulkhann
Follow for more!