Questions tagged [plot]

10365 questions
1

votes
1

answer
1.4k

Views

How to change the line colour for different lines in a subplot

I'm looking to be able to change the colours of lines to ones that I specify on a plot using matplotlib. Below is the relevant code (it's part of a function) that I'm using. The variable avg_rel_trackis a '2D array' and each column corresponds to a 'blade'. Each 'blade' plots a separate line. I wou...
Ashleigh Clayton
1

votes
2

answer
4.8k

Views

Plotting square() and sawtooth() in Octave

I was trying to plot a square wave and a saw-tooth wave in Octave, but it gave an error saying >>>error: 'sawtooth' undefined near line 17 column 6 error: 'square' undefined near line 17 column 6 >>>error: 'x1' undefined near line 17 column 21 error: evaluating argument list element number 2 >>>erro...
Tanay PrabhuDesai
0

votes
0

answer
15

Views

Plotting a Line Plot in Pandas on a double-indexed dataframe

I have a dataframe as shown below with double index 'month' and 'day' query_sorted_gross = ''' SELECT days.Gross, days.month, days.day FROM days, horror_movies WHERE horror_movies.'Movie ID' = days.'Movie ID' ''' df_q1 = pd.read_sql_query(query_sorted_gross, conn) df_q1_grouped = df_q1.groupby(['mon...
Amit Gelbhart
1

votes
1

answer
506

Views

R_plotting points in multiple plots

I have two plots and I want to add some additional lines to both plots. Is there a way in R to choose the plot (among the two) to draw the new lines? Edit1: Actually I have multiple plots in one window using mfrow Edit2: I have edited the the question to include the problem i faced after using mfgi...
MaMu
0

votes
0

answer
7

Views

how to create an empty 2D array and create a mesh grid

I have defined the equations as functions previous to this. I am trying to plot a mesh grid of a and b with ml. However i am aware i need a 2D array for my 'ml' values and for a and b. Can someone help me out with what is wrong with my code and to produce a mesh grid ? #defining function def lyapun...
Natalie Nugent
0

votes
1

answer
13

Views

plot() call thinks that data.frame is atomic vector

I have a data.frame, irv, with a column of interest. class(irv) returns 'data.frame'. is.recursive(irv) returns TRUE, is.atomic(irv) returns FALSE. In the console, irv$x returns the column of interest. max(irv$x) also returns the appropriate max value. Inside a plot call I am attempting to set the x...
C. Denney
1

votes
1

answer
109

Views

How to plot ylabel in panda MultiIndex Dataframe

I need to plot a MultiIndex Dataframe with ylabels from level 0 of the columns. The Dataframe is as follows: PCs pc1 pc2 pc3 \ explained_variance_ratio 9.977643e-01 2.196399e-03 3.275875e-05 wavelength...
1

votes
1

answer
2.1k

Views

Python: Matplotlib: Vertically aligned plots in matplotlib

I would like to read data from multiple sources and plot them above each other. The way I need them to be plotted is by having a single x-axis labeled at the bottom, and the others should be aligned with the same x-axis, no matter what points are available. The following is an example of the problem...
1

votes
1

answer
2.5k

Views

Adding label on a D3 scatter plot circles

I trying to add a label to each circle of a scatter plot using D3.js but can't figure it out. Here is the code: https://jsfiddle.net/8e7qmzw8/; I want to add the attribute 'name' to each circle (inside or outside). var data = [ {'x': -123, 'y': 63, 'r': 37, 'c': '#50C2E3', 'name': 'A'}, {'x': 71, 'y...
mounibec
1

votes
2

answer
8.6k

Views

How to change the legend box width when plotting in R

I use the following script to generate a legend in R. But the legend box is too small... how do I increase the box width? legend('topleft', lty = 1, legend = c('Sub_metering_1','Sub_metering_2','Sub_metering_3'),col = c('black','red','blue'))
Ziwei
1

votes
1

answer
183

Views

How to get axis ticks on a Date axis

For usual axis we can get the tick values with axTicks. If x is a Date, this attempt fails. x
Andri Signorell
1

votes
1

answer
2.7k

Views

ACF plot title change?

I wish to change the title that this simple acf plot would create, but I am unsure how to do so, as it defaults to the variable name d.sales2. AutoCorrelation
Saif
1

votes
1

answer
421

Views

Centering matplotlib legend entries within incomplete/unfilled rows?

Say I'm making a plot with five items, and only have room to create a legend with 3 columns (more columns than this would be too wide), e.g. import matplotlib.pyplot as plt f, a = plt.subplots() for i in range(5): a.plot(np.arange(10),np.random.rand(10),label='Item #%d'%i) a.legend(ncol=3) The trail...
Luke Davis
1

votes
1

answer
27

Views

How to make plot.data.frame with more than two columns work with par(mfrow)

When I call plot on a data frame with two [numeric] columns and par set to give me two columns of plots, I get the expected behavior: par(mfrow = c(1, 2)) d
Empiromancer
1

votes
3

answer
2.2k

Views

How to plot keys and values from dictionary in histogram

I need to plot a histogram with the following dictionary x = {5:289, 8:341, 1:1565, 4:655, 2:1337, 9:226, 7:399, 3:967, 6:405} I need first keys be ordered from 1 to 9. Then the values will be plotted in the histogram, showing a maximum probability of 1.0. I have tried the following (plus other stuf...
Daniel
1

votes
1

answer
767

Views

Scatter plot of 2 variables with colorbar based on third variable

I am trying to plot with variable x with respect to another y and add a colormap based on the values of another variable z So the plot should be similar to this My try import numpy as np import pandas as pd import seaborn as sns import random import matplotlib.pyplot as plt import matplotlib.cm as c...
gis20
1

votes
2

answer
64

Views

Quantmod Heikin-Ashi plotting unavailable

Recently I have been working with the quantmod package of R. The idea is to use shiny package to design the user interface of the web app while using quantmod functions to plot graphs of stock data for users. Nonetheless, from the documentation of source code, there seems to be no pre-written functi...
Mr.Benson
1

votes
3

answer
24

Views

Missing labels in matplotlib pie chart

I try to plot a pie chart using Python 3 Matplotlib v2.2.2-4build1 on Ubuntu 18.10. Everything seems to be ok except labels - they are missing. Tried to add it according to official documentation (https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pie.html), tried to use an example from the web (h...
Dmitriy Vinokurov
1

votes
1

answer
26

Views

Live plotting using tcl/tk canvas

I am trying to plot live changes in a file using tcl/tk canvas utility. I have written a simple code to find the difference in file and plot it using .c create line $oldx $oldy $newx $newy command. My code has a while loop to keep checking for changes in the file. When I comment out the while loop,...
guptasonal
1

votes
1

answer
16

Views

Add an aditional space to xrange and yrange

I want to plot multiple files using a Gnuplot script. However, I'm having some trouble to make it perfect. My actual plots are something like that: However, the linepoints plot is touching both the x-axis and the y-axis. Therefore, I want to add extra space on xrange and yrange and get which does n...
Iago Carvalho
-1

votes
0

answer
12

Views

Error message while saving a .pgf figure with LaTeX code on axis

I am having an error trying to save a .pfg using Pylab. The error comes from the xlabel, where I added some LaTeX commands: title('$Ley \ de \ Snell \ de \ la \ reflexión$') xlabel('$ \\theta_r \ [\\degree]$') ylabel('$ \\theta_i \ [^{\\circ}]$') legend(['$Datos \ exprimentales$','$Recta \ de \ aju...
Peybol
0

votes
0

answer
2

Views

How do I add a density curve to my Histogram

Hi guys Im trying to figure out how to add a line of best fit to my histogram. My R coding skills are about 1 week old aka non existent so basic explanations would help. This is my code for the Histogram hist(Examscores$math score[Examscores$gender=='male'], ylim = c(0, 150), xlab = 'Percentage Re...
0

votes
0

answer
15

Views

Plotting time intervals as segments

I have the following dataframe: test_df system type start_date end_date event_duration #> 1 A 2 2015-05-12 2016-07-13 428 #> 2 B 2 2015-06-18 2016-07-02 380 #> 3 B 2 2014-09-11 2015-08-14 337 #> 4 C 2 2015-06-09 2016-04-18...
DeltaIV
1

votes
1

answer
67

Views

Why does ggplot not plot when storing to variable?

I thought this was obvious, but recently I was using the package openair and noticed that when I run the following: library(openair) myplot
rjss
0

votes
2

answer
14

Views

Pandas Plot: scatter plot with index [duplicate]

This question already has an answer here: Scatter plot form dataframe with index on x-axis 1 answer I am trying to create a scatter plot from pandas dataframe, and I dont want to use matplotlib plt for it. Following is the script df: group people value 1 5 100 2 2 90 1 10 80 2...
Manu Sharma
5

votes
2

answer
158

Views

Seaborn Factorplot generates extra empty plots below actual plot

All, I am trying to plot two Factorplots using subplots function and Seaborn library. I was able to plot two plots separately using below code. However, seaborn is generating extra plot below the actual plots (see below image) . Is there a way to avoid seaborn to generate extra empty plot ? I tried...
Data_is_Power
0

votes
0

answer
3

Views

plot different columns in one graph R

My sample data : structure(list(year = c(2018, 2018, 2018, 2018, 2019, 2019), month = c(9, 10, 11, 12, 1, 2), pred1 = c(-6.63356483810535, -6.50968293287978, -1.54767782423655, -1.47812226859267, -1.36788275407234, -1.28168637109063), pred2 = c(-1.42361872090391, -1.3982815502715, -1.14092414754...
Lalitha
0

votes
0

answer
7

Views

How to create overlay plots from 20 CSV files in Python 2?

I generate 20 CSV files per each long calculation I do in python 2. From all data sets, I need to plot the third set from each file superimposed. I am not a programmer but I can plot them individually as per: import matplotlib.pyplot as plt import csv x = [] y = [] with open('energy.csv','r') as cs...
pal
2

votes
0

answer
21

Views

Scatter plot multiclass labels

I'm trying to implement SMOTE technic and thus I would like to visualize my labels. This technic helps me solve the data imbalance problem. I have, say, 1000 labels of 1, 2, and 3 and the counts are 100, 100, 800 respectively. After SMOTE, I will add synthetic values so that I will have 800, 800, a...
iso_9001_
1

votes
1

answer
345

Views

Bar chart in matplotlib shows less bars when having big range on x coordinates

What am I doing wrong here with a bar chart in python and matplotlib? The first plot is good, the second has a much wider range on the x-axis up to 1500. Notice in the second plot that most of the bars on the low scale disappear, but also the bar at 1500 is not shown. I tried setting the width=0.8...
aless80
1

votes
1

answer
6.1k

Views

How to customize marker colors and shapes in scatter plot?

I have a data set with 9 columns. 7 features are used for feature selection and one of them for the classification. I used tsne library for feature selection in order to see how much my data could be classified.The result from tsne is shown in picture. However, I want to visualize my data in anothe...
Elham
1

votes
1

answer
358

Views

Remove a single label from ggplot legend

Example code: library(ggplot2) library(RcppRoll) library(reshape2) test_data2=data.frame(dates2015
sym246
1

votes
2

answer
617

Views

Can data points be labeled in stripcharts?

I can't find a way to label datapoints in stripchart. Using the text function, as suggested in this question, breaks down when points are stacked or jittered. I have numerical data in 4 categories (columns 2-5) and would like to label each datapoint with the initials (column 1). This is my data and...
SeanJ
1

votes
2

answer
82

Views

Plotting rank for various models under different criteria in R

I have data like this : RMSE MAE MAPE CDC GARCH 1 2 2 3 eGARCH 2 1 3 2 csGARCH 3 3 4 1 apGARCH 4 4 1 4 GARCH, eGARCH,..,apGARCH are various models and they are ranked by four criteria RMSE, MAE, MAPE, and CDC. I want to plot this data in a si...
Neeraj
1

votes
1

answer
246

Views

How to plot 2D Voronoi grid on 3D axes, within bounds?

I have a straightforward function to plot a Voronoi diagram, which works nice when plotting on 2D axes. However, when I plot the 2D grid on a plane on 3D axes, it overflows. Here is the code: function plotHexGrid(X, Y, m, n) f1 = figure [XV YV] = voronoi(X(:),Y(:)); plot(XV,YV,'b-'); axis([...
Manon
1

votes
1

answer
48

Views

When setting ColorOrder in Matlab, first point doesn't change color

I'm plotting cell arrays against each other and I want certain groups of points to have the same color. I made a new color order matrix and all the points changed to the correct color EXCEPT the very first one. It's stuck on the default blueish color. The variables are contained in cells so I'm loo...
rinzler12
1

votes
1

answer
113

Views
1

votes
2

answer
1.5k

Views

Use matplotlib: plot error bars on two y axes

I'd like to plot a series with x and y error bars, then plot a second series with x and y error bars on a second y axis all on the same subplot. Can this be done with matplotlib? import matplotlib.pyplot as plt plt.figure() ax1 = plt.errorbar(voltage, dP, xerr=voltageU, yerr=dPU) ax2 = plt.errorbar(...
Sam Sinnamon
1

votes
1

answer
98

Views

How to change size of grid & granularity in meshc function

Show mask by meshc function z = [0 0 0 0;0 1 1 0;0 0 0 0]; meshc(z) Output is: Desired output:
Mohammad

View additional questions