- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1034 Articles for Matplotlib
98 Views
To make matplotlib.pyplot stop forcing the style of markers, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create random x and y data points using numpy.Plot x and y data points using plot() method, with "r*" marker with markersize=10.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.random.rand(20) y = np.random.rand(20) plt.plot(x, y, 'r*', markersize=10) plt.show()Output
10K+ Views
To set the limits on a colorbar of a countour plot in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Get the data using x and y.Get the coordinate matrices from the coordinate vectors.Initialize vmin and vmax to set the limits on a colorbar of a contour plot in matplotlib.Plot contours using contourf() method.Make the colorbar using scalar mappable within the range of vmin and vmax.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import numpy as np from ... Read More
92 Views
To make xtick labels of a plot be simple drawings using Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize the y position of simple drawings.Create a new figure or activate an existing figure using figure() method.Add an '~.axes.Axes' to the figure as part of a subplot arrangement using add_subplot()method.Plot a line using plot() method.Set the X-axis ticks using set_ticks() method.Set empty tick labels.Add circles and rectangles patches using add_patch() method. Instantiate Circle() and Rectangle() class.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import matplotlib.patches as patches ... Read More
414 Views
To indicate the statistically significant difference in bar graph, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create means, std, index, width and labels data points.Create a figure and a set of subplots using subplots() method.Make a bar plot using bar() method.Plot Y versus X as lines and/or markers with attached errorbars.Scale the Y-axis.Get or set the current tick locations and labels of the X-axis.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True means = (5, 15, ... Read More
1K+ Views
To show node name in graphs using networkx, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize a graph with edges, name, or graph attributes.Add multiple nodes using add_nodes_from() method.Add all the edges using add_edge_from() method.Draw the graph G with Matplotlib using draw() method. Set with_labels to True.To display the graph, we can use show() method.Exampleimport matplotlib.pylab as plt import networkx as nx plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True G = nx.DiGraph() G.add_nodes_from([1, 2, 3, 4]) G.add_edges_from([(1, 2), (2, 1), (2, 3), (1, 4), (3, 4)]) nx.draw(G, ... Read More
843 Views
To add a title on Seaborn Implot, we can take the following steps−Set the figure size and adjust the padding between and around the subplots.Make a Pandas dataframe with two columns, X-Axis and Y-AxisUse implot() method.Get the current axis using gca() method.To display the figure, use show() method.Exampleimport pandas import matplotlib.pylab as plt import seaborn as sns import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pandas.DataFrame({"X-Axis": [np.random.randint(10) for i in range(10)], "Y-Axis": [i for i in range(10)]}) bar_plot = sns.lmplot(x='X-Axis', y='Y-Axis', data=df, height=3.5) ax = plt.gca() ax.set_title("Random Data Implot") ... Read More
634 Views
To plot a transparent Poly3DCollection plot in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplotsCreate a new figure or activate an existing figure.Add an '~.axes.Axes' to the figure as part of a subplot arrangement with projection=3d.Create x, y and z data points.Make a list of vertices.Convert x, y and z data points into a zipped list of tuples.Get a list of instance of Poly3d.Add a 3D collection object to the plot using add_collection3d() method.Turn off the axes.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt ... Read More
889 Views
To plot two horizontal bar charts sharing the same Y-axis, we can use sharey=ax1 in subplot() method and for horizontal bar, we can use barh() method.StepsCreate lists for data points.Create a new figure or activate an existing figure using figure() methodAdd a subplot to the current figure using subplot() method, at index=1.Plot horizontal bar on axis 1 using barh() method.Add a subplot to the current figure using subplot() method, at index=2. Share the Yaxis of axis 1.Plot the horizontal bar on axis 2.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, ... Read More
7K+ Views
To remove a specific line or curve in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Plot line1 and line2 using plot() method.Pop the second line and remove it.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt, image as mimg plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True line_1 = plt.plot([1, 2, 3]) line_2 = plt.plot([2, 4, 6]) line = line_2.pop(0) line.remove() plt.show()Output