# Questions tagged [plot]

The graphical representation of a mathematical function or a set of data. There are different kinds of plots, such as line plots, bar plots, or scatter plots.

25,523 questions

**0**

votes

**0**answers

12 views

### trying to plot Naive Bayes output but getting error - 'x' is a list, but does not have components 'x' and 'y'

I'm trying to plot a naive bayes output but getting
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' is a list, but does not have components 'x' and 'y'
I used plot(nb). My dependent ...

**0**

votes

**0**answers

18 views

### how to modify seaborn violin plot legend

I have created a simple violin plot from a bands DataFrame (df10 below) using seaborn:
fig, ax = plt.subplots(figsize=(10,4))
ax = sns.violinplot(x='z', y='z_fit', hue='new_col', data=df10, cut=0, ...

**1**

vote

**1**answer

41 views

### Dataframe : each column in different plot in subplot

I have a panda Dataframe which i want each column to be represented on each subplot( 2 dimensions)
i know the default subplot of pandas is the desired output but 1 dimensional:
pallet 45 46 ...

**-2**

votes

**0**answers

24 views

### Asymmetric axes plot

I am trying to generate a plot a vector field between two plots.
The data i am trying to plot is computed per layer and x direction. so there are a 100 layers and 200 x points, so that generates a ...

**0**

votes

**1**answer

18 views

### Lattice barchart with correct spaces between columns

I have another lattice question. Suppose I draw bar chart with this code:
require(lattice)
data <- data.frame(x = c(1,7,10,14,20,21), y = c(0.1,0.6,0.4,0.5,0.3,0.7))
barchart(data$y ~ data$x, ...

**1**

vote

**1**answer

23 views

### Filling circles in lattice scatter plot by condition

I have the following code:
require(lattice)
data <- data.frame(x = c(1,1,2,3,4,5), y = c(5,1,4,6,1,7),
color = c("red", "red", "black", "blue", "yellow", "red"))
data$size <-...

**-1**

votes

**1**answer

24 views

### Hanging bar plot from dplyr

I am trying to figure out how to create a hanging bar plot from dplyr.
I have used dplyr as follows:
table4 <- cr %>%
group_by(samp.N, RSQ) %>%
summarize(
MRB_uc = mean(CF.F1F2/0....

**0**

votes

**1**answer

32 views

### Plot 3D in R: Classical spectral gasoline in function of octane

Load a data set comprising spectral intensities of 60 samples of gasoline at 401 wavelengths, and their octane ratings in pls package. In my example:
library(pls)
#Data set
data(gasoline)
'data....

**2**

votes

**3**answers

64 views

### Optimize the rejection method for generating variables

I have a problem with optimization of the rejection method of generating continuous random variables. I've got a density: f(x) = 3/2 (1-x^2). Here's my code:
import random
import matplotlib.pyplot ...

**1**

vote

**0**answers

24 views

### What are set_xlim() and set_ylim() in matplotlib?

Here is the question about applying some limits on x and y axis of the canvas.
I have found the function for limits but I am not getting their purpose. What are they used for?
fig1 = plt.figure()
...

**0**

votes

**0**answers

12 views

### Analysing the residual normal probability plot

It's very basic question. I want to analyze the standardized residuals of the Linear Regression model. So I did the residual normal probability plot as following:
model = LinearRegression(...

**0**

votes

**1**answer

17 views

### Plotting a parabola - NotImplementedError

Problem statement and attempt at problem
I'm trying to write code for the given problem, but I keep receiving a "NotImplementedError" and I don't understand what this means or how to fix my code to ...

**0**

votes

**0**answers

13 views

### how to change the xvalues in ts.plot

I am currently trying to plot a time series using ts.plot. In my data frame, the first column is the years while the rest are the variables.
If I try to ts.plot the entire data frame using:
ts.plot(...

**0**

votes

**0**answers

27 views

### How to get multiple legends but with same color breaks with plot function in r?

I have three rasters:
first one:
class : RasterBrick
dimensions : 47, 89, 4183, 6 (nrow, ncol, ncell, nlayers)
resolution : 0.5, 0.5 (x, y)
extent : 60.75, 105.25, 15.75, 39.25 (...

**0**

votes

**2**answers

51 views

### How to plot a vector field using Numpy?

The idea is to plot the following vector field:
I have two main issue with it:
1) I do not know how to make sure that the arrows are not too long (I know I have to use length, but how?).
2) I am ...

**0**

votes

**1**answer

45 views

### How to create a single legend for a group of bar charts generated from a dataframe

I have a dataframe as shown in the code and I generated a barh chart for each row using a loop. I am trying to plot a single legend for all the charts on the bottom-right corner but without success. I ...

**3**

votes

**1**answer

37 views

### Separating seaborn barplot with two colors

I have the following dataset:
words = ['upvoted', 'upvote', 'f***', 'reimer', 'feminists', 'censorship',
'wet', '0001f914', 'turtle', '0001f602', 'vegans', 'thumbnail',
'lobby', 'mods', ...

**0**

votes

**1**answer

36 views

### How to display difference between two points from two different glyphs in Bokeh using HoverTool?

I have two lines in a plot and I want to displace the difference of each pair of points on hover using HoverTool.
I tried '@y' - '@yhat', float('@y') - float('@yhat'), @y - @yhat, but nothing worked.

**0**

votes

**0**answers

5 views

### Dynamically change text wrapping and/or orientation for labels in Bokeh?

I'm trying to create a nested treemap in Bokeh. I can create the rectangles, properly sized and nested, and plot them, but I cannot label them. When I use LabelSet and add the layout, the labels are ...

**1**

vote

**1**answer

13 views

### How to get equally scaled axes with Plots in Julia

I have created a heatmap plot using in Julia by using the Plotly with the Plots package. I generate the heatmap with the following command heatmap(10^9 .* (height + deformation)). Then, I get a plot ...

**1**

vote

**2**answers

29 views

### Overlaying plots with log and lin axes in R

I am trying to graph two datasets on the same plot. The sets have the same x values. One set should be plotted on a log scale in y, the other should be plotted on a lin scale in y. For this post a ...

**0**

votes

**0**answers

25 views

### ho can I get a (variables) values from a plot

I want to know if there is any way in python to determine automatically the values of (a, and b) in the x-axis. i.e. the values when my plot knows a markable decrease and when It know a markable ...

**0**

votes

**0**answers

17 views

### Surface over plain plot

Is there a way to generate a figure where the surface is over the plain plot? Like in the figure below. Notice that not only the contour and countourf would be used, but something more to add the 3D ...

**1**

vote

**1**answer

22 views

### Accessing same value for all elements in dictionary of tuples

I have a dictionary containing keys all with a 7-tuple as their values. For every 7-tuple, each of the 7 values represents a different property corresponding to the data set that key is representing. ...

**0**

votes

**1**answer

26 views

### Pandas subplot layout not working in this case

I was plotting some scatter plot of mpg dataset from the seaborn library. I was wondering if it is possible to plot the odd number of subplots in python?
import pandas as pd
import seaborn as sns
df =...

**0**

votes

**0**answers

13 views

### PyqtGraph RemoveItem removes only last line

I am working on a DAQ GUI. While collecting test data, the user can choose between PlotWidgets to show the plot on. This is done by choosing check boxes for graphs. When the check box is not checked, ...

**0**

votes

**0**answers

41 views

### How to shift the origin of the y axis in Matlab

I am plotting some data (A and B) in Matlab. When I use plot(A,'-b'); hold on; plot(B, '-r') command, the data are automatically plotted with an x axis from 0 to 1100, and the y axis from -10 to 10. ...

**0**

votes

**2**answers

22 views

### DataFrame not able to assign values to axis with Bokeh DataColumnSource

I do not understand why I can not assign the values to the axes, I specified every column within the source.
If someone can help me please, I would appreciate.
The data is from http://data.un.org/
(...

**1**

vote

**1**answer

25 views

### How to zoom in to raster plot (setting limits to raster)

I have plotted an overlay map of hillshade and landslide susceptibilities. I would like to zoom in on a particular area of the plot.
landslide_raster_pred <-predict(ta,landslide_model, type ="...

**0**

votes

**0**answers

18 views

### How to combine multiple 2D R plots into a single 3D plot

I am trying to stack multiple 2d plots into a single 3d plot in R.
For example, I want to try and put these plots
into a single 3d image. The z axis would be the biomass density, y axis be the ...

**4**

votes

**3**answers

51 views

### How to fix wrong alignment of vector annotation head in Matlab if y-Direction is set to 'reverse'

the code
figure
scatter([1,2,3],[1,2,3]);
ax = gca;
ax.YDir ='reverse'
ah = annotation('arrow','position',[ 2.5 2.5 -1 -1]);
set(ah,'parent',ax);
gives a wrong vector head alignment:
Any ideas how ...

**2**

votes

**1**answer

31 views

### How to plot a parametric curve without using `plot3d_parametric_line`

The idea is to plot the curve: C(t) = (1 + cos(t))i + (1 + sin(t))j + (1 -sin(t)-cos(t))k. Following the instructions on the Plot Module at https://docs.sympy.org/latest/modules/plotting.html one can ...

**0**

votes

**0**answers

19 views

### How to make a bar plot when all variables are in different columns?

I'd like to make a graph but have no idea how to achieve that. It seems simple. Data looks like: https://i.stack.imgur.com/sbudV.jpg
The result should be: https://i.stack.imgur.com/p4dN1.jpg
Can you ...

**-2**

votes

**1**answer

21 views

### How to add a Poisson distribution curve that approaches 3?

I want to add a curve to an existing plot.
This curve should be a poisson distribution curve that approaches the mean 3.
I've tried this code
points is a vector with 1000 values
plot(c(1:1000), ...

**1**

vote

**1**answer

42 views

### Combine base and ggplot graphics in sub figures of graphic device

I want to produce an array of plots using base R, each with their own insert plot based on ggplot, aligned to the right, slightly lower than top right so that I can add some text above. Something like ...

**0**

votes

**0**answers

24 views

### How to plot a stacked graph by separating values in a single column to several series in R?

Imagine I have the following dataset, df:
DateTime Person Distance_walked
2019-01-01 00:10:00 A 200
2019-01-01 00:20:00 A ...

**0**

votes

**0**answers

26 views

### Plot function sometimes gives syntax error [on hold]

I am trying to animate interference of two waves in single dimension. The animation works great if I do not change the color or other variables of the plot. But it gives syntax error when I introduce ...

**2**

votes

**1**answer

44 views

### smooth plotting all columns of a data-frame

I have a data frame of:
Index Date AA BB CC DD EE FF
0 2019-01-15 0.0 -1.0 0.0 0.0 0.0 2.0
1 2019-01-17 0.0 -1.0 -1.0 -1.0 0.0 2.0
2 2019-01-22 ...

**-1**

votes

**2**answers

25 views

### How to plot a histogram with various variables in python?

I have a scenario where I have a dataset in which there are results of India's total ODI matches played since 2018 with each and every team. If India won 5 matches out of 6 with South Africa, then the ...

**0**

votes

**1**answer

12 views

### How do I show the last Y-axis value next to the curve? [duplicate]

i'm trying to figure out how I can get my chart to show the latest (last) Y-axis value in the time series next to the curve line. Currently I have the below graph. I've tried using 'plt.text' but this ...

**0**

votes

**1**answer

15 views

### text() in R on plot - how to keep on a single line without wrapping?

I often use R to run batch jobs that contain PDF outputs with scatter plots produced using a combination of plot() and points(), among other graphical functions. (I don't use ggplot much and would ...

**-3**

votes

**1**answer

36 views

### How to Make a Beautiful Stacked 3D Plot [on hold]

I am looking to make a plot where:
Plot is composed of a group of 2D plots, stacked in 3D.
The height of the line is indicated by the color.
This is what I mean:

**1**

vote

**1**answer

30 views

### Is there a way to see data on different time-scales on the same X-axis?

So I am trying to set up a chart in python to show the development of an inter-month spread over the year (i.e. Oct/Nov 2015, Oct/Nov 2016, and so on).
Currently when I plot, it shows me the whole ...

**0**

votes

**1**answer

22 views

### Matplotlib produces unwanted tabbed windows for plt

I simply want to plot two separate plots (i.e. plots in separate windows) using python (anaconda installation) and matplotlib. But when I run the example code below, I get a single window that ...

**0**

votes

**1**answer

19 views

### How to avoid overlapping of labels in timeline plot

Hey everyone, i use the plot example from https://matplotlib.org/gallery/lines_bars_and_markers/timeline.html
Code is similar from the example there. Just some different values for the list names and ...

**0**

votes

**0**answers

15 views

### Why a full grown classification tree produce error in plot function?

I construct a full classification tree. The online suggestion is to set cp=-1 to get a full grown tree.
If i now use the plotcp(PartizipationsModell2015Gini) function i get the following warning:
...

**-2**

votes

**1**answer

22 views

### the plot generated by galton's family dataset seem to be wrong

I downloaded galton's family dataset and use the following code to plot.
df = pd.read_csv('Galton.csv')
X = df.iloc[:,1]
y = df.iloc[:,2]
plt.scatter(X,y)
and I got this plot
which seems to be not ...

**0**

votes

**2**answers

44 views

### Is there a better way to plot an array?

I would please like to know, if there is a better way to plot a nx2 matrix
This is how I do:
%... matrix
A = [2 4 2 6 8; 9 8 7 6 4];
%plot
column1 = A(:,1);
column2 = A(:,2);
plot(column1, ...

**0**

votes

**0**answers

19 views

### How to fix Omnet++ Visualization for my results (Chart see data but don't plot it)

I'm setting everythink like in tutorial says (Chapter 7.5) https://docs.omnetpp.org/tutorials/tictoc/part7/
(Haven't reputation to post image ;/)
My module to plot a chart is seeing data and I can ...

**1**

vote

**1**answer

26 views

### ggplot2: Varying facet width with independent `Y` axes

Dummy data
d = data.frame(
x = factor(LETTERS[c(1,2,3,4,1,2,3,4,1,2,1,2,1,2,1,2)]),
y = c(100,80,70,60,130,90,65,60,2,3,3,3,2,2,1,2),
grid = rep(letters[1:2], each=8)
)
Issue
ggplot(d, ...