- 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 change the color and add grid lines to a Python Matplotlib surface plot?
To change the color and add grid lines to a Python surface plot, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create x, y and h data points using numpy.
Create a new figure or activate an existing figure.
Get 3D axes object, with figure (from Step 3).
Create a surface plot, with orange color, edgecolors and linewidth.
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.arange(-5, 5, 0.25) y = np.arange(-5, 5, 0.25) x, y = np.meshgrid(x, y) h = np.sin(x)*np.cos(y) fig = plt.figure() ax = Axes3D(fig) ax.plot_surface(x, y, h, rstride=10, cstride=10, color='orangered', edgecolors='yellow', lw=0.6) plt.show()
- How to change the color of a plot frame in Matplotlib?
- How to change the face color of a plot using Matplotlib?
- How to surface plot/3D plot from a dataframe (Matplotlib)?
- How to set same color for markers and lines in a Matplotlib plot loop?
- How to add vertical lines to a distribution plot (sns.distplot) in Matplotlib?
- Plotting a masked surface plot using Python, Numpy and Matplotlib
- How to change the color of the axis, ticks and labels for a plot in matplotlib?
- How to change the plot line color from blue to black in Matplotlib?
- How to remove lines in a Matplotlib plot?
- How to plot overlapping lines in Matplotlib?
- How to remove grid lines from an image in Python Matplotlib?
- How to plot the lines first and points last in Matplotlib?
- How to draw grid lines behind Matplotlib bar graph?
- How to create a surface plot from a greyscale image with Matplotlib?
- How to customize the color and colormaps of a Plot in Matplotlib