Wednesday, July 10, 2019

How to Plot Charts in Python with Matplotlib

You generate a huge amount of data on a daily basis. A critical part of data analysis is visualization. A variety of graphing tools have developed over the past few years. Given the popularity of Python as a language for data analysis, this tutorial focuses on creating graphs using a popular Python library — Matplotlib.

Matplotlib is a huge library, which can be a bit overwhelming for a beginner — even if one is fairly comfortable with Python. While it is easy to generate a plot using a few lines of code, it may be difficult to comprehend what actually goes on in the back-end of this library. This tutorial explains the core concepts of Matplotlib so that one can explore its full potential.

Let's get started!

Prerequisites

The library that we will use in this tutorial to create graphs is Python's matplotlib. This post assumes you are using version 3.0.3. To install it, run the following pip command in the terminal.

pip install matplotlib==3.0.3

To verify the version of the library that you have installed, run the following commands in the Python interpreter.

>>> import matplotlib
>>> print(matplotlib.__version__)
'3.0.3'

If you are using Jupyter notebooks, you can display Matplotlib graphs inline using the following magic command.

%matplotlib inline

Pyplot and Pylab: A Note

During the initial phases of its development, Mathworks' MATLAB influenced John Hunter, the creator of Matplotlib. There is one key difference between the use of commands in MATLAB and Python. In MATLAB, all functions are available at the top level. Essentially, if you imported everthing from matplotlib.pylab, functions such as plot() would be available to use.

This feature was convenient for those who were accustomed to MATLAB. In Python, though, this could potentially create a conflict with other functions.

Therefore, it is a good practice to use the pyplot source.

from matplotlib import pyplot as plt

All functions such as plot() are available within pyplot. You can use the same plot() function using plt.plot() after the import earlier.

Dissecting a Matplotlib Plot

The Matplotlib documentation describes the anatomy of a plot, which is essential in building an understanding of various features of the library.


Source

The major parts of a Matplotlib plot are as follows:

  • Figure: The container of the full plot and its parts
  • Title: The title of the plot
  • Axes: The X and Y axis (some plots may have a third axis too!)
  • Legend: Contains the labels of each plot

Each element of a plot can be manipulated in Matplotlib's, as we will see later.

Without further delay, let's create our first plot!

Create a Plot

Creating a plot is not a difficult task. First, import the pyplot module. Although there is no convention, it is generally imported as a shorter form &mdash plt. Use the .plot() method and provide a list of numbers to create a plot. Then, use the .show() method to display the plot.

from matplotlib import pyplot as plt
plt.plot([0,1,2,3,4])
plt.show()

Your first plot with matplotlib

Notice that Matplotlib creates a line plot by default. The numbers provided to the .plot() method are interpreted as the y-values to create the plot. Here is the documentation of the .plot() method for you to further explore.

Now that you have successfully created your first plot, let us explore various ways to customize your plots in Matplotlib.

Customize Plot

Let us discuss the most popular customizations in your Matplotlib plot. Each of the options discussed here are methods of pyplot that you can invoke to set the parameters.

The post How to Plot Charts in Python with Matplotlib appeared first on SitePoint.


by Shaumik Daityari via SitePoint

Facebook and its privacy issues: What Did Apple Co-founder Steve Wozniak say about it?

You have realized that you need to do it but you are afraid to do it. Maybe you are thinking that it will hurt your friends or family if you would delete your Facebook account. However, Apple’s co-founder, Steve Wozniak is worried because of Facebook and its existence on its device. TMZ’s...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by aqsqa qadir via Digital Information World

Firefox 68 and dark patterns at scale

#399 — July 10, 2019

Read on the Web

Frontend Focus

Firefox 68: BigInts, Contrast Checks, and the QuantumBar — Version 68 is now available, featuring support for big integers, whole-page contrast checks, and a new implementation of a core Firefox feature: the URL bar.

Dan Callahan (Mozilla)

CSS Lists, Markers, And Counters — There’s a lot more to styling lists using CSS than you might think, says Rachel Andrew, including using the new ::marker pseudo-element introduced with this week’s Firefox 68 release (featured above). If you want to be the up-to-date CSS list expert in the office this week, read this.

Rachel Andrew

Image & Video Management Made for Front-End Developers — Simplify and automate the process of uploading, manipulating, optimizing, and delivering images and videos across every device at any bandwidth. Try Cloudinary. See how easy media management can be. Get your own free account today.

Cloudinary sponsor

Dark Patterns at Scale: Findings from a Crawl of 11K Shopping Websites — The findings from a large-scale study, analyzing ~53K product pages from ~11K shopping websites to characterize and quantify the prevalence of dark user interface patterns.

Princeton University and University of Chicago

An Intro To Screen Reader Testing for Sighted Developers — This quick guide will give you an introduction to the why and how of testing your website’s user experience using screen readers.

Uncaught Reference Error Blog

Chrome to Get Video Play/Pause Button on the Toolbar — Google Chrome users will soon have a quicker way to pause auto-playing media across all tabs in their browser. This feature is in the Canary build now.

Catalin Cimpanu

The Future of Websites: Headless CMSes? — An increasing number of CMS’s have been shunning traditional database-driven systems in favor of API driven ones, known as “headless CMS”es. Here’s a run through some pros and cons of the approach.

Dan Fries

๐Ÿ’ป Jobs

Frontend Senior Software Engineer & Architect at TrainingPeaks — Bring your engineering best practices to the brand helping athletes and coaches around the world analyze and plan their training.

TrainingPeaks

Front-end Engineer — Goldstar is looking for Front-end Engineers with React expereince onsite in Portland, Oregon and Pasadena, California.

Goldstar

Job Searching Without the Searching? Try hackajob ๐Ÿ”Ž — Let your skills do the talking. Get matched to roles based on your favourite frontend frameworks.

hackajob

๐Ÿ“™ Tutorials & Opinion

The Many Ways to Include CSS in JavaScript Apps — A look at the ways in which CSS can be handled within a JavaScript application — something of a controversial topic in the land of frontend development. I like option 1.

Dominic Magnifico

CSS Architecture for Multiple Websites — Elad shares his knowledge and experience from writing a reusable and scalable CSS architecture for use across multiple websites.

Elad Shechter

The Little Legacy Code That Could: A Fable of Software Ownership — A lack of software ownership isn’t a simple problem, but we have a few recommendations that can help your teams.

CircleCI sponsor

Developing a Robust Font Loading Strategy for CSS-Tricks — Zach takes a look at the font loading behavior for the latest redesign of the popular CSS-Tricks site.

Zach Leatherman

Fun Places to Learn CSS Layout – Grid Layout — We’ve linked to a few of these in the past, but here’s a good round-up of some fun places, tutorials and sandbox sites to help you learn Grid Layout.

Stรฉphanie Walter

Responsive Design Ground Rules — Some ground rules to follow to keep your responsive design robust and predictable.

Polypane

Creating A Multi-Level Hierarchical Flyout Navigation Menu Using Only HTML and CSS

Abhishek Ghosh

A Little Reminder That Pseudo Elements are Children, Kinda

Chris Coyier

How Google Pagespeed Works: How to Improve Your Score

Ben Schwarz

๐Ÿ”ง Code, Tools & Resources

Pie Chart Maker: An Easy Way to Create Pie Charts — A free tool to create good looking customizable pie charts. Insert your data and it offers up a JPG, PNG, or even an animated version to embed.

Beautiful Dingbats

p5.js: A Client-Side JS Platform for Creative, Arty Coding — This mature project has just had a big release. Check out some of the examples in the live p5.js playground for a feel for how cool this is – it makes putting together visualizations and visual experiments very easy.

Processing Foundation

Web Audio DAW: Using the Web Audio API for Dynamic Sound Synthesis — A Javascript library for manipulating audio using the HTML Web Audio API. “It’s like jQuery for your ears”.

Raphael Serota

Proactively Identify & Improve Issues Before They Affect Customers with Datadog Synthetics

Datadog sponsor

simpleParallax: A JavaScript Library for Parallax Effects — A straightforward, tiny library which adds parallax animation to any image.

Geoffrey Signorato

FormPersistence.js: Preserve HTML Form Data Across Sessions — If people start to fill out a form, why not keep the data around in their local storage in case they leave and come back?

Finn Thompson

   ๐Ÿ—“ Upcoming Events

An Event Apart, July 29-31 — Washington, D.C. — A popular three-day conference that focuses on all things relating to digital design and user experience.

WebAIM: Web Accessibility Training, August 13-14 — Logan, Utah — Covers everything from basic web accessibility principles to advanced accessibility techniques.

Front Conference, August 29-30 — Zurich, Switzerland — A two-day double-track conference for everyone involved from concept to implementation.

Web Unleashed 2019, September 13-14 — Toronto, Canada — Covers a variety of front-end topics leaving you 'informed, challenged and inspired'.

CSSConf, September 25 — Budapest, Hungary — A community conference dedicated to the designers and developers who love CSS.


by via Frontend Focus

Twitter launches new policies to stop attacks on religious groups

Twitter is one of the popular social platforms due to its ability for freedom of speech for its users. Twitter is a social platform where users have the ability to share their thoughts and ideas without the fear of being judged at all. Twitter - a platform struggling with hate speechTwitter can be...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by agha ali via Digital Information World

New iCloud Update Could Introduce Face Recognition/Fingerprint Sign-Ins

Some people don’t really like the fact that the world has become so mobile phone centric. This is one of the main reasons why Apple has a website that you can visit in order to access your iCloud. People that are using devices that they don’t trust or are not familiar with would be able to access...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Zia Zaidi via Digital Information World

Instagram challenges ‘bullying’ on social media with new features

The popular social media app announced two new features on Monday that are designed to minimize negative interactions. According to a press release by Instagram, online bullying is a serious issue. Unfortunately, it is ongoing for years. And even after significant investment in technology, the...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Saima Salim via Digital Information World

How to Use LinkedIn to Turn Cold Prospects Into Warm Leads

Do you want more warm leads from LinkedIn? Wondering how to use LinkedIn to schedule more calls or meetings with new leads? In this article, you’ll discover how to use four LinkedIn marketing features to nurture leads. #1: Recommend a Group Post for More Exposure to All LinkedIn Group Members In the past, LinkedIn groups […]

The post How to Use LinkedIn to Turn Cold Prospects Into Warm Leads appeared first on Social Media Marketing | Social Media Examiner.


by Josh Turner via Social Media Marketing | Social Media Examiner