Rishikesh Kumar Rishi has Published 1162 Articles

How to change the color of data points based on some variable in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:32:15

959 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 ... Read More

How to put a legend outside the plot with Pandas?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:31:53

6K+ 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 ... Read More

How to make pylab.savefig() save image for 'maximized' window instead of default size in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:31:14

1K+ 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 ... Read More

How can I show figures separately in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:30:32

15K+ 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 ... Read More

Automatically position text box in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:25:06

591 Views

To position a textbox automatically in matplotlib, we can take the following Steps −Create xpoints from 1 to 2 and 100 samples.Create y1points and y2points using xpoints (Step 1) and numpy.Plot xpoints, y1points and y2points using the plot() method.To set the label, use the legend() method. It will help to position the text box.To display the figure, ... Read More

What are the differences between add_axes and add_subplot in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:24:42

369 Views

Definingadd_axes − Add an axes to the figure.add_subplot − Add an axes to the figure as part of a subplot arrangement.StepsCreate a new figure, or activate an existing figure, using the figure() method.Add an axes to the figure as part of a subplot arrangement where nrows=2, ncols=2. At index 1, add ... Read More

How to change the curve using radiobuttons in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:21:36

311 Views

To change the color of a line using radiobuttons, we can take the following steps −Create x, sin and cos data points using numpy.Adjust the figure size and padding between and around the subplots.Create a figure and a set of subplots using the subplots() method.Plot curve with x and y ... Read More

Pythonic way of detecting outliers in one dimensional observation data using Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:19:37

119 Views

To detect outliers in one dimensional observation data, we can take the following Steps −Create spread, center, flier_high and flier_low.Using the above data (Step 1), we can calculate data.Use the suplots() method to create a figure and a set of subplots, i.e., fig1 and ax1.Set the title of ax1.Now using ... Read More

Golang program to calculate the absolute and scale of a vertex.

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 18-Mar-2021 12:27:19

183 Views

ExampleAbs(x, y) => √(x)2+(y)2Scale(f) => (x*f, y*f)ApproachDefine a vertex as a struct.Initialize the vertex with some x and value.Define a method to calculate absolute(x, y).Define a method to calculate scale(x*f, y*f).Example Live Demopackage main import (    "fmt"    "math" ) type Vertex struct {    X, Y float64 } func ... Read More

Golang program to traverse a given input array, with Boolean flag, using arrays and struct.

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 18-Mar-2021 12:25:52

164 Views

ExampleApproachAsk the user to enter the size of array.Make a string array of given size.Ask the user to enter elements.At the end, print the array.Example Live Demopackage main import "fmt" func main(){    arr := []int{10, 20, 30, 60, 40, 50}    boolArr := []bool{true, false, true, false, true, false}   ... Read More

Advertisements