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.

Wikipedia uses the following definition of plot:

A plot is a graphical technique for presenting a data set drawn by hand or produced by a mechanical or electronic plotter. It is a graph depicting the relationship between two or more variables used, for instance, in visualising scientific data.

Plots help greatly in visualizing the structure of your data, or the outcome of an analysis. Good plots yield insight into the data, which is often hard to gain from just looking at the numbers.

roughly has three separate systems which provide plotting facilities:

  • Base plot: these are the plot routines standardly available in R. The syntax works roughly equivalent to MATLAB. The first one creates a plot, then additional calls to, for example, points or lines adds additional graphical features to the plot.
  • lattice: which provides an implementation of Trellis graphics (S-PLUS) for R.
  • ggplot2: a loose implementation of the grammar of graphics for R.

Different programming platforms support a variety of plot options. Noteworthy are Python's - a 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms, Matlab's and Mathematica's plot provides the starting point for 2-D line plots, and so forth.

Another widely used library is ; which is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. For a brief introduction to the ideas behind the library, you can read the introductory notes. Here are a few examples to see what you can do with seaborn.

An additional plotting library is . Gnuplot offers easy plotting that can be done through the command line interface. It works for Mac, Windows, Linux, and other operating systems. Gnuplot is very powerful because of the range of options when it comes to types of plots (2d, 3d, histogram, etc.) and the output formats (PNG, EPS, SVG, etc.). More info can be seen here.


Related tags

37452 questions
139
votes
6 answers

How can I plot with 2 different y-axes?

I would like superimpose two scatter plots in R so that each set of points has its own (different) y-axis (i.e., in positions 2 and 4 on the figure) but the points appear superimposed on the same figure. Is it possible to do this with plot? Edit…
DQdlM
  • 9,814
  • 13
  • 37
  • 34
139
votes
2 answers

Prevent scientific notation

I have the following code: plt.plot(range(2003,2012,1),range(200300,201200,100)) # several solutions from other questions have not worked, including # plt.ticklabel_format(style='sci', axis='x', scilimits=(-1000000,1000000)) #…
Travis Osterman
  • 1,493
  • 2
  • 10
  • 4
139
votes
3 answers

Control the size of points in an R scatterplot?

In R, the plot() function takes a pch argument that controls the appearance of the points in the plot. I'm making scatterplots with tens of thousands of points and prefer a small, but not too small dot. Basically, I find pch='.' to be too small,…
Nick
  • 21,555
  • 18
  • 47
  • 50
134
votes
7 answers

Plot a bar using matplotlib using a dictionary

Is there any way to plot a bar plot using matplotlib using data directly from a dict? My dict looks like this: D = {u'Label1':26, u'Label2': 17, u'Label3':30} I was expecting fig = plt.figure(figsize=(5.5,3),dpi=300) ax =…
otmezger
  • 10,410
  • 21
  • 64
  • 90
133
votes
4 answers

How to make a 3D scatter plot

I am currently have a nx3 matrix array. I want plot the three columns as three axis's. How can I do that? I have googled and people suggested using Matlab, but I am really having a hard time with understanding it. I also need it be a scatter plot.
user211037
  • 1,725
  • 5
  • 16
  • 11
132
votes
1 answer

Position geom_text on dodged barplot

I tried to make the title self-explanatory, but here goes - data first: dtf <- structure(list(variable = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L), .Label = c("vma", "vla", "ia", "fma", "fla"), class = "factor"), ustanova =…
aL3xa
  • 35,415
  • 18
  • 79
  • 112
132
votes
11 answers

How to draw an empty plot?

I need to make an empty plot. This is the best could I come up with. plot(0, xaxt = 'n', yaxt = 'n', bty = 'n', pch = '', ylab = '', xlab = '') Any simpler solutions? P.S.: completely empty, no axis etc.
Adam SO
  • 9,821
  • 8
  • 28
  • 27
127
votes
4 answers

Matplotlib Legends not working

Ever since upgrading matplotlib I get the following error whenever trying to create a legend: /usr/lib/pymodules/python2.7/matplotlib/legend.py:610: UserWarning: Legend does not support [] Use proxy…
Mike Vella
  • 10,187
  • 14
  • 59
  • 86
127
votes
8 answers

Rotating x axis labels in R for barplot

I am trying to get the x axis labels to be rotated 45 degrees on a barplot with no luck. This is the code I have below: barplot(((data1[,1] - average)/average) * 100, srt = 45, adj = 1, xpd = TRUE, …
David
  • 2,834
  • 6
  • 26
  • 31
126
votes
14 answers

Error in plot.new() : figure margins too large in R

I'm new to R but I've made numerous correlation plots with smaller data sets. However, when I try to plot a large dataset (2gb+), I can produce the plot just fine, but the legend doesn't show up. Any advice? or alternatives? library(gplots) r.cor <-…
Steve Hwang
  • 1,589
  • 4
  • 14
  • 12
125
votes
3 answers

Change values on matplotlib imshow() graph axis

Say I have some input data: data = np.random.normal(loc=100, scale=10, size=(500,1,32)) hist = np.ones((32, 20)) # initialise hist for z in range(32): hist[z], edges = np.histogram(data[:, 0, z], bins=np.arange(80, 122, 2)) I can plot it using…
Lee
  • 29,398
  • 28
  • 117
  • 170
122
votes
18 answers

How to plot ROC curve in Python

I am trying to plot a ROC curve to evaluate the accuracy of a prediction model I developed in Python using logistic regression packages. I have computed the true positive rate as well as the false positive rate; however, I am unable to figure out…
user3847447
  • 1,291
  • 3
  • 11
  • 8
119
votes
4 answers

How to plot two columns of a pandas data frame using points

I have a pandas dataframe and would like to plot values from one column versus the values from another column. Fortunately, there is plot method associated with the data-frames that seems to do what I need: df.plot(x='col_name_1',…
Roman
  • 124,451
  • 167
  • 349
  • 456
118
votes
6 answers

Subscripts in plots in R

I can't find a way how to write subscripts in the title or the subtitle in R. How can I write v 1,2 with 1,2 as subscripts? Thanks for your help!
jeffrey
  • 2,026
  • 5
  • 28
  • 42
117
votes
3 answers

How to show Y axis label horizontally

I'm creating very simple charts with matplotlib / pylab Python module. The letter "y" that labels the Y axis is on its side. You would expect this if the label was longer, such as a word, so as not to extend the outside of the graph to the left too…
Karl D
  • 1,295
  • 2
  • 8
  • 5