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
176
votes
3 answers

Plotting a list of (x, y) coordinates in matplotlib

I have a list of pairs (a, b) that I would like to plot with matplotlib in python as actual x-y coordinates. Currently, it is making two plots, where the index of the list gives the x-coordinate, and the first plot's y values are the as in the pairs…
CodeKingPlusPlus
  • 15,383
  • 51
  • 135
  • 216
175
votes
3 answers

Remove space between plotted data and the axes

I have the following dataframe: uniq <- structure(list(year = c(1986L, 1987L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 2014L,…
Jaap
  • 81,064
  • 34
  • 182
  • 193
174
votes
8 answers

Plot smooth line with PyPlot

I've got the following simple script that plots a graph: import matplotlib.pyplot as plt import numpy as np T = np.array([6, 7, 8, 9, 10, 11, 12]) power = np.array([1.53E+03, 5.92E+02, 2.04E+02, 7.24E+01, 2.72E+01, 1.10E+01,…
Paul
  • 4,239
  • 6
  • 28
  • 29
174
votes
5 answers

Remove plot axis values

I was just wondering if there is a way to get rid of axis values, either the x-axis or y-axis respectively, in an r-plot graph. I know that axes = false will get rid of the entire axis, but I would only like to get rid of the numbering.
user130633
  • 2,253
  • 4
  • 18
  • 11
168
votes
3 answers

How to export plots from matplotlib with transparent background?

I am using matplotlib to make some graphs and unfortunately I cannot export them without the white background. In other words, when I export a plot like this and position it on top of another image, the white background hides what is behind it…
Cupitor
  • 11,007
  • 19
  • 65
  • 91
164
votes
8 answers

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

I've looked in different questions for a solution and I've tried what was suggested but I have not found a solution to make it work. Everytime I want to run this code it always says: Error in plot.new() : figure margins too large and I don't know…
user3530361
  • 1,651
  • 2
  • 11
  • 5
159
votes
4 answers

Moving x-axis to the top of a plot in matplotlib

Based on this question about heatmaps in matplotlib, I wanted to move the x-axis titles to the top of the plot. import matplotlib.pyplot as plt import numpy as np column_labels = list('ABCD') row_labels = list('WXYZ') data = np.random.rand(4,4) fig,…
Jason Sundram
  • 12,225
  • 19
  • 71
  • 86
158
votes
3 answers

Putting text in top left corner of matplotlib plot

How can I put text in the top left (or top right) corner of a matplotlib figure, e.g. where a top left legend would be, or on top of the plot but in the top left corner? E.g. if it's a plt.scatter(), then something that would be within the square…
user248237
158
votes
5 answers

How to plot multiple functions on the same figure

How can I plot the following 3 functions (i.e. sin, cos and the addition), on the domain t, in the same figure? import numpy as np import matplotlib.pyplot as plt t = np.linspace(0, 2*np.pi, 400) a = np.sin(t) b = np.cos(t) c = a + b
user3277335
  • 1,947
  • 2
  • 15
  • 16
157
votes
6 answers

how to draw directed graphs using networkx in python?

I have some nodes coming from a script that I want to map on to a graph. In the below, I want to use Arrow to go from A to D and probably have the edge colored too in (red or something). This is basically, like a path from A to D when all other…
brain storm
  • 30,124
  • 69
  • 225
  • 393
150
votes
4 answers

Annotate bars with values on Pandas bar plots

I was looking for a way to annotate my bars in a Pandas bar plot with the rounded numerical values from my DataFrame. >>> df=pd.DataFrame({'A':np.random.rand(2),'B':np.random.rand(2)},index=['value1','value2'] ) >>> df A …
leroygr
  • 2,349
  • 4
  • 18
  • 18
149
votes
10 answers

Getting LaTeX into R Plots

I would like to add LaTeX typesetting to elements of plots in R (e.g: the title, axis labels, annotations, etc.) using either the combination of base/lattice or with ggplot2. Questions: Is there a way to get LaTeX into plots using these packages,…
DrewConway
  • 5,407
  • 7
  • 35
  • 32
148
votes
3 answers

Move X-Axis label downwards, but not X-Axis Ticks in matplotlib

I'm using Matplotlib to plot a histogram. Using tips from my previous question: Matplotlib - label each bin, I've more or less got the kinks worked out. There's one final issue - previously - the x-axis label ("Time (in milliseconds)") was being…
victorhooi
  • 16,775
  • 22
  • 90
  • 113
142
votes
10 answers

What is the best open-source java charting library? (other than jfreechart)

Why are there not more opensource easy to use charting libraries for Java?. The only successful opensource project in this area seems to be jfreechart, and it doesn't even have any documentation or examples available.
fccoelho
  • 6,012
  • 10
  • 55
  • 67
140
votes
4 answers

Increase distance between text and title on the y-axis

The y-axis title appears too close to the axis text. ggplot(mpg, aes(cty, hwy)) + geom_point() I have tried changing the value of many parameters with theme() but none seems to help.
Ernest A
  • 7,526
  • 8
  • 34
  • 40