Visualization Errors

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 34

Visualization Errors

PREPARED BY
R.AKILA,AP(SG)
BSACIST
For any scientific measurement, accurate accounting
for errors is nearly as important.
Basic Errorbars
A basic errorbar can be created with a single
Matplotlib function call
Here the fmt is a format code controlling the
appearance of lines and points.
Continuous Errors
Density and Contour Plots

Sometimes it is useful to display three-dimensional data


in two dimensions using contours or color-coded
regions. 
There are three Matplotlib functions that can be helpful
for this task: plt.contour for contour
plots, plt.contourf for filled contour plots,
and plt.imshow for showing images.
contour plot can be created with the plt.contour function.
It takes three arguments: a grid of x values, a grid
of y values, and a grid of z values.
The x and y values represent positions on the plot, and
the z values will be represented by the contour levels.
use the np.meshgrid function, which builds two-
dimensional grids from one-dimensional arrays
By default when a single color is used, negative
values are represented by dashed lines, and positive
values by solid lines. 
Imshow() function

plt.imshow() doesn't accept an x and y grid, so you must


manually specify the extent [xmin, xmax, ymin, ymax] of
the image on the plot.
plt.imshow() by default follows the standard image array
definition where the origin is in the upper left, not in the
lower left as in most contour plots.
plt.imshow() will automatically adjust the axis aspect
ratio to match the input data;
this can be changed by setting, for
example, plt.axis(aspect='image') to make x and y units
match.
Histogram

A simple histogram can be a great first step in


understanding a dataset.
Two-Dimensional Histograms and Binnings

create histograms in one dimension by dividing the


number-line into bins, we can also create histograms
in two-dimensions by dividing points among two-
dimensional bins.
Hexagonal binnings

Matplotlib provides the plt.hexbin routine, which


will represents a two-dimensional dataset binned
within a grid of hexagons:
Customizing Plot Legends
Plot legends give meaning to a visualization,
assigning meaning to the various plot elements.
Customizing Colorbars

Plot legends identify discrete labels of discrete


points. For continuous labels based on the color of
points, lines, or regions, a labeled colorbar can be a
great tool.
In Matplotlib, a colorbar is a separate axes that can
provide a key for the meaning of colors in a plot.
Three different categories of colormaps

Sequential colormaps: These are made up of one


continuous sequence of colors
(e.g., binary or viridis).
Divergent colormaps: These usually contain two
distinct colors, which show positive and negative
deviations from a mean (e.g., RdBu or PuOr).
Qualitative colormaps: these mix colors with no
particular sequence (e.g., rainbow or jet).
Text and Annotation

Creating a good visualization involves guiding the


reader so that the figure tells a story. 
This story can be told in an entirely visual manner,
without the need for added text, but in others, small
textual cues and labels are necessary.
A plot of average births over the course of the
calendar year;
Arrows and Annotation

Drawing arrows in Matplotlib is often much harder


than you'd bargain for. While there is
a plt.arrow() function available.
plt.annotate() function. This function creates some
text and an arrow, and the arrows can be very
flexibly specified.
The arrow style is controlled through
the arrowprops dictionary, which has numerous
options available. 

You might also like