
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
Found 26504 Articles for Server Side Programming

448 Views
To hide matplotlib.lines.Line2D instance while calling the plot() method, we can take the following steps −Import numpy as np.From matplotlib, import pyplot as plt.Create points for x, i.e., np.linspace(1, 10, 1000)Now plot the line using the plot() method.To hide the instance, use plt.plot(x); (with semi colon)Or, use _ = plt.plot(x).ExampleIn [1]: import numpy as np In [2]: from matplotlib import pyplot as plt In [3]: x = np.linspace(1, 10, 1000) In [4]: plt.plot(x) Out[4]: [] In [5]: plt.plot(x); In [6]: _ = plt.plot(x) In [7]:OutputOut[4]: []

403 Views
To change the figuresize using Seaborn factorplot, we can take the following Steps −Load the exercise data using load_dataset() method.Using factorplot() method, change figure size by customising the size and aspect values.To display the figure, use the show() method.Exampleimport seaborn as sns from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True exercise = sns.load_dataset("exercise") sns.factorplot("kind", "pulse", "diet", exercise, kind="point", size=5, aspect=2) plt.show()Output

4K+ Views
To embed small plots inside subplots, we can take the following Steps −Using subplots() method, create a figure and a set of subplots (fig, ax1).On ax1, plot a line with color red, line width=4, label=”outer plot”.Using add_axes(), add an axis, i.e., ax2 with l, b, h and w values.Plot the same points (Step 2) usins the plot() method, with color green, line width=3, label=”inside plot”.Set the legend on both the plots using the legend() method.To display the figure, use the show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax1 = plt.subplots() ax1.plot([1, 4, ... Read More

2K+ Views
To set the font size of matplotlib axis legend, we can take the following steps −Create the points for x and y using numpy.Plot x and y using the plot() method with label y=sin(x).Title the plot using the title() method.To set the fontsize, we can override rcParams legend fontsize by value 20.Use the legend() method, and fit the legend at the top-right position.To display the figure, use the show() method.Exampleimport numpy as np from matplotlib import pyplot as plt import matplotlib plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(1, 10, 50) y = np.sin(x) plt.plot(x, y, c="red", lw=7, label="y=sin(x)") ... Read More

225 Views
In this tutorial, we are going to write a program that checks whether the given number is k-rough or k-jagged number or not.The number whose smallest prime factor is greater than or equal to the given k, it is called k-rough or k-jagged number.Let's see the steps to solve the problem.Initialise the numbers n and k.Find all the prime numbers that are factors of n and store them in a vector.Get the first element from the vector and compare it with k to check whether n is k-rough or k-jagged number or not.ExampleLet's see the code. Live Demo#include using namespace ... Read More

13K+ Views
To show the origin, we can take the following Steps −Create the points x, y1 and y2 using numpy.Plot the sine and cosine curves using plot() methods.Plot the vertical line, i.e., x=0.Plot the horizontal line, i.e., y=0.Intersection point of (Step 3 and 4), could be the origin.To display the label of lines, use legend() method.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(1, 10, 50) y1 = np.sin(x) y2 = np.cos(x) plt.plot(x, y1, c="orange", label="y=sin(x)") plt.plot(x, y2, c="green", label="y=cos(x)") plt.axvline(x=0, c="red", label="x=0") plt.axhline(y=0, c="yellow", ... Read More

1K+ Views
To change the color of data points based on some variable in matplotlib, we can take the following steps −Create x, y and c variables using numpy.Plot the scatter points using x, y and for color, use c (Step 1).To display the image, use the show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(1, 20, 50) y = np.log(x) c = np.random.randint(x) plt.scatter(x, y, c=c) plt.show()Output

7K+ Views
To put a legend outside the plot with Pandas, we can take the following Steps −Make a dictionary d with keys Column1 and Column2.Make a data frame using DataFrame (d).Plot the data frame with a list of styles.Using legend(), place a legend on the figure. The bbox_to_anchor keyword gives a great degree of control for manual legend placement. For example, if you want your axes legend located at the figure's top right-hand corner instead of the axes' corner, simply specify the corner's location, and the coordinate system of that location.To display the figure, use the show() method.Exampleimport pandas as pd from ... Read More
How to make pylab.savefig() save image for 'maximized' window instead of default size in Matplotlib?

2K+ Views
To save image for maximized window instead of default size, we can use the following Steps −Create figure with figsize=(7.50, 3.50), using the figure() method.Plot the lines using the plot() method with list, color=”red”, and linewidth=2.Save the figure using the savefig() method.To display the figure, use the show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() plt.plot([1, 3, 7, 3, 1], c="red", lw=2) plt.savefig("full_image.png") plt.show()Output

17K+ Views
To show multiple figures in matplotlib, we can take the following Steps −To create a new figure, or activate an existing figure, use the figure() method. (Create two figures namely, Figure1 and Figure2).Plot the lines with the same lists (colors red and green and linewidth 2 and 5).Set the title of the plot over both the figures.To display the figure, use the show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig1 = plt.figure("Figure 1") plt.plot([1, 3, 7, 3, 1], c="red", lw=2) plt.title("I am the part of figure 1") fig2 = plt.figure("Figure 2") plt.plot([1, 3, ... Read More