
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 1318 of 3368

3K+ Views
First, we can initialize the dictionary with col1 and col2, convert it into a data frame. After that, we can plot this data with ‘o’ and ‘rx’ style.StepsCreate a dictionary with Column 1 and Column 2 as the keys and Values are like i and i*i, where i is from 0 to 10, respectively.Create a data frame using pd.DataFrame(d); d created in step 1.Plot the data frame with ‘o’ and ‘rx’ style.To show the plot, use plt.show().Exampleimport pandas as pd from matplotlib import pyplot as plt d = {'Column 1': [i for i in range(10)], 'Column 2': [i*i for ... Read More

953 Views
Using matplotlib.get_backend(), we can get the backend value.StepsImport matplotlib.To return the name of the current backend, use the get_backend() method.Exampleimport matplotlib print("Backend used by matplotlib is: ", matplotlib.get_backend())OutputBackend used by matplotlib is: GTK3Agg

2K+ Views
We can iterate a plot using display.clear_output(wait=True), display.display(pl.gcf()) and time.sleep() methods in a loop to get the exact output.StepsPlot a sample (or samples) from the "standard normal" distribution using pylab.randn().Clear the output of the current cell receiving output, wait=False(default value), wait to clear the output until new output is available to replace it.Display a Python object in all frontends. By default, all representations will be computed and sent to the frontends. Frontends can decide which representation is used and how, using the display() method. pl.gcf helps to get the current figure.To sleep for a while, use time.sleep() method.Exampleimport time import ... Read More

490 Views
First, we can create an image using imshow method, taking a harvest matrix. After that, we can mark those image pixels with some value.StepsCreate a list of subjects.Create a list of students.Create a harvest matrix.Create fig and ax variables using subplots method, where default nrows and ncols are 1.Display data as an image, i.e., on a 2D regular raster, with step 1 data.Get or set the current tick locations and labels of the X-axis, with the length of students.Get or set the current tick locations and labels of the Y-axis, with the length of subjects.Set X-axis tick labels of the ... Read More

982 Views
Using imshow method, we can create an image with an input (5, 5) array dimension. After that, we can use the xticks and yticks method to mark the ticks on the axes.StepsReturn random floats in the half-open interval [5, 5) and interpolation='nearest'.Display data as an image, i.e., on a 2D regular raster, with step 1 data.Get or set the current tick locations and labels of the X-axis, using xticks method.Get or set the current tick locations and labels of the Y-axis, using yticks method.Use plt.show() to show the figure.Exampleimport matplotlib.pyplot as plt import numpy as np plt.imshow(np.random.random((5, 5)), interpolation='nearest') ... Read More

2K+ Views
To get a 3D plot, we can use fig.add_subplot(111, projection='3d') method to instantiate the axis. After that, we can use the scatter method to draw different data points on the x, y, and z axes.StepsCreate a new figure, or activate an existing figure.Add an `~.axes.Axes` to the figure as part of a subplot arrangement, where nrows = 1, ncols = 1, index = 1 and projection is ‘3d’.Iterate a list of marks, xs, ys and zs, to make scatter points.Set x, y, and z labels using set_xlabel, y_label, and z_label methods.Use plt.show() method to plot the figure.Exampleimport matplotlib.pyplot as plt import ... Read More

8K+ Views
Using plt.xticks(x, labels, rotation='vertical'), we can rotate our tick’s label.StepsCreate two lists, x, and y.Create labels with a list of different cities.Adjust the subplot layout parameters, where bottom = 0.15.Add a subplot to the current figure, where nrow = 1, ncols = 2 and index = 1.Plot the line using plt.plot(), using x and y (Step 1).Get or set the current tick locations and labels of the X-axis. Pass no arguments to return the current values without modifying them, with x and label data.Set or retrieve auto-scaling margins, value is 0.2.Set the title of the figure at index 1, the ... Read More

8K+ Views
Using plt.colorbar(ticks=np.linspace(-2, 2, 5)), we can create a discrete color bar.StepsReturn random floats in the half open interval, i.e., x, using np.random.random method.Return random floats in the half open interval, i.e., y, using np.random.random method.Return random integers from `low` (inclusive) to `high` (exclusive), i.e., z, using np.random.randint(-2, 3, 20) method.Set the X-axis label using plt.xlabel().Set the Y-axis label using plt.ylabel().Use the built-in rainbow colormap.Generate a colormap index based on discrete intervals.A scatter plot of *y* vs. *x* with varying marker size and/or color, with x, y and z are created (Steps 1, 2, 3).Create a colorbar for a ScalarMappable instance, ... Read More

34K+ Views
First, we can define our dictionary and then, convert that dictionary into keys and values. Finally, we can use the data to plot a bar chart.StepsCreate a dictionary, i.e., data, where milk and water are the keys.Get the list of keys of the dictionary.Get the list of values of the dictionary.Plot the bar using plt.bar().Using plt.show(), show the figure.Exampleimport matplotlib.pyplot as plt data = {'milk': 60, 'water': 10} names = list(data.keys()) values = list(data.values()) plt.bar(range(len(data)), values, tick_label=names) plt.show()Output

5K+ Views
Using plt.get_current_fig_manager() and mng.full_screen_toggle() methods, we can maximise a plot.StepsAdd a subplot to the current figure, where nrow = 1, ncols = 1 and index = 1.Create a pie chart using list [1, 2, 3] and pie() method.Return the figure manager of the current figure, using get_current_fig_manager() method. The figure manager is a container for the actual backend-depended window that displays the figure on the screen.Create an abstract base class to handle drawing/rendering operations using the full_screen_toggle() method.Use plt.show() to show the figure.Exampleimport matplotlib.pyplot as plt plt.subplot(1, 1, 1) plt.pie([1, 2, 3]) mng = plt.get_current_fig_manager() mng.full_screen_toggle() plt.show()OutputRead More