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
237
votes
7 answers

Add missing dates to pandas dataframe

My data can have multiple events on a given date or NO events on a date. I take these events, get a count by date and plot them. However, when I plot them, my two series don't always match. idx = pd.date_range(df['simpleDate'].min(),…
KHibma
  • 2,927
  • 4
  • 20
  • 25
236
votes
9 answers

Plotting in a non-blocking way with Matplotlib

I am having problems trying to make matplotlib plot a function without blocking execution. I have tried using show(block=False) as some people suggest, but all I get is a frozen window. If I simply call show(), the result is plotted properly but…
opetroch
  • 3,929
  • 2
  • 22
  • 24
236
votes
3 answers

Label points in geom_point

The data I'm playing with comes from the internet source listed below nba <- read.csv("http://datasets.flowingdata.com/ppg2008.csv", sep=",") What I want to do, is create a 2D points graph comparing two metrics from this table, with each player…
Green Demon
  • 4,078
  • 6
  • 24
  • 32
231
votes
4 answers

xkcd style graphs in MATLAB

So talented people have figured out how to make xkcd style graphs in Mathematica, in LaTeX, in Python and in R already. How can one use MATLAB to produce a plot that looks like the one above? What I have tried I created wiggly lines, but I couldn't…
bla
  • 25,846
  • 10
  • 70
  • 101
222
votes
10 answers

Format y axis as percent

I have an existing plot that was created with pandas like this: df['myvar'].plot(kind='bar') The y axis is format as float and I want to change the y axis to percentages. All of the solutions I found use ax.xyz syntax and I can only place code…
Chris
  • 12,900
  • 12
  • 43
  • 65
216
votes
10 answers

Plot a legend outside of the plotting area in base graphics?

As the title says: How can I plot a legend outside the plotting area when using base graphics? I thought about fiddling around with layout and produce an empty plot to only contain the legend, but I would be interested in a way using just the base…
Henrik
  • 14,202
  • 10
  • 68
  • 91
212
votes
2 answers

What do hjust and vjust do when making a plot using ggplot?

Every time I make a plot using ggplot, I spend a little while trying different values for hjust and vjust in a line like + opts(axis.text.x = theme_text(hjust = 0.5)) to get the axis labels to line up where the axis labels almost touch the axis,…
William Gunn
  • 2,925
  • 8
  • 26
  • 22
207
votes
6 answers

How do I tell Matplotlib to create a second (new) plot, then later plot on the old one?

I want to plot data, then create a new figure and plot data2, and finally come back to the original plot and plot data3, kinda like this: import numpy as np import matplotlib as plt x = arange(5) y = np.exp(5) plt.figure() plt.plot(x, y) z =…
Peter D
  • 3,283
  • 4
  • 24
  • 23
207
votes
1 answer

What is the difference between pylab and pyplot?

What is the difference between matplotlib.pyplot and matplotlib.pylab? Which is preferred for what usage? I am a little confused, because it seems like independent from which I import, I can do the same things. What am I missing?
Claus
  • 4,409
  • 4
  • 19
  • 16
205
votes
8 answers

How do I tell matplotlib that I am done with a plot?

The following code plots to two PostScript (.ps) files, but the second one contains both lines. import matplotlib import matplotlib.pyplot as plt import matplotlib.mlab as mlab plt.subplot(111) x = [1,10] y = [30, 1000] plt.loglog(x, y, basex=10,…
Stefano Borini
  • 138,652
  • 96
  • 297
  • 431
201
votes
4 answers

Force the origin to start at 0

How can I set the origin / interception of the y-axis and x-axis in ggplot2? The line of the x-axis should be exactly at y=Z. With Z=0 or another given value.
Jonas Stein
  • 6,826
  • 7
  • 40
  • 72
196
votes
9 answers

How to increase font size in a plot in R?

I am confused. What is the right way to increase font size of text in the title, labels and other places of a plot? For example x <- rnorm(100) hist(x, xlim=range(x), xlab= "Variable Label", ylab="density", main="Title of plot", prob=TRUE,…
Tim
  • 1
  • 141
  • 372
  • 590
182
votes
15 answers

Most underused data visualization

Histograms and scatterplots are great methods of visualizing data and the relationship between variables, but recently I have been wondering about what visualization techniques I am missing. What do you think is the most underused type of…
Ian Fellows
  • 17,228
  • 10
  • 49
  • 63
180
votes
7 answers

matplotlib get ylim values

I'm using matplotlib to plot data (using plot and errorbar functions) from Python. I have to plot a set of totally separate and independent plots, and then adjust their ylim values so they can be easily visually compared. How can I retrieve the…
synaptik
  • 8,971
  • 16
  • 71
  • 98
177
votes
5 answers

Rotating axis labels in R

How do I make a (bar) plot's y axis labels parallel to the X axis instead of parallel to the Y axis?
Phoebe
  • 2,774
  • 3
  • 22
  • 27