routing and switching room at Cisco, a dream was born...
Today, Cisco certifications are the gold standard in IT training. We’ve issued more than 4 million certifications so far. In the next 30 years, we aim to train over 10 million more people in our pledge to close the IT skills gap and reshape diversity in the tech industry.
99%
of organizations surveyed use technical certifications to make hiring decisions.
91%
of employers believe IT certifications are a reliable predictor of a successful employee.
Making informative visualizations is called as Plots, important task in data analysis
In exploratory analysis – identifying outliers, data transformations ,generating models visualization can be used.
Matplotlib is a desktop plotting package designed for creating publication-quality plots.
Project started by John Hunter to enable MATLAB like plotting interface in python.
Making informative visualizations is called as Plots, important task in data analysis
In exploratory analysis – identifying outliers, data transformations ,generating models visualization can be used.
Matplotlib is a desktop plotting package designed for creating publication-quality plots.
Project started by John Hunter to enable MATLAB like plotting interface in python.
Making informative visualizations is called as Plots, important task in data analysis
In exploratory analysis – identifying outliers, data transformations ,generating models visualization can be used.
Matplotlib is a desktop plotting package designed for creating publication-quality plots.
Project started by John Hunter to enable MATLAB like plotting interface in python.
Describes three plotting systems in R: base, lattice and ggplot2. Example code can be found here: https://github.com/TriangleR/PlottingSystemsInR
This document discusses how to create line charts, bar charts, pie charts, histograms, and scatter plots using Matplotlib in Python. It covers how to import Matplotlib, customize line styles, colors, markers, legends, titles and labels. It provides code examples for plotting single and multiple lines, formatting plots, saving figures, and using different chart types like pie charts, bar charts and histograms.
Looking for a computer institute to learn Full Stack development and Digital Marketing? Our institute offers comprehensive courses in both areas, providing students with the skills and knowledge needed to succeed in today's digital landscape
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
To let the world know about our product, we check open-source projects. By the moment we have checked 245 projects. A side effect: we found 9574 errors and notified the authors about them.
1. The document discusses various types of plots that can be created using matplotlib in Python, including line plots, bar graphs, histograms, pie charts, frequency polygons, box plots, and scatter plots.
2. It describes how to customize plots by changing colors, styles, widths, and adding labels, titles, and legends.
3. Examples are provided for creating different plot types like line charts, bar graphs, histograms, and customizing aspects of the plots.
Matplotlib is a 2D plotting library for Python that can generate publication-quality figures in both hardcopy and interactive formats. The document provides examples of using Matplotlib to plot lines, histograms, pie charts, scatter plots, subplots, and mathematical functions. Additional resources are also listed for learning more about Matplotlib and an example dataset on apple production by variety.
Towards typesafe deep learning in scalaTongfei Chen
Deep learning is predominantly done in Python, a type-unsafe language. Try changing this unfortunate fact by doing it in Scala instead! With expressive types, compile-time typechecking, and awesome DSLs, we present Nexus, a typesafe, expressive and succinct deep learning framework.
Here are the steps to plot the given functions using MATLAB:
1. Plot y = 0.4x + 1.8 for 0 ≤ x ≤ 35 and 0 ≤ y ≤ 3.5:
x = 0:35;
y = 0.4.*x + 1.8;
plot(x,y)
xlim([0 35])
ylim([0 3.5])
2. Plot imaginary vs real parts of 0.2 + 0.8i*n for 0 ≤ n ≤ 20:
n = 0:20;
z = 0.2 + 0.8i*n;
plot(real(z),imag(z))
xlabel('Real Part')
Why Data Visualization?
What is Data Visualization?
What is matplotlib?
Types of charts
Basic of matplotlib
Bar chart,
Histogram
Pie chart
Scatter chart
Stack plot
Subplot
References
adding extra feature to all types of chart like Bar chart, Histogram, Stack plot
Use the Matplotlib, Luke @ PyCon Taiwan 2012Wen-Wei Liao
Matplotlib is a Python 2D plotting library that produces publication-quality figures in both hardcopy and interactive environments across platforms. It provides both object-oriented and MATLAB-style state machine interfaces. Matplotlib can be used to create simple plots with just a few commands or customize plots extensively by manipulating the object properties of figures, axes, and artists.
Tall-and-skinny Matrix Computations in MapReduce (ICME MR 2013)Austin Benson
Tall-and-skinny Matrix Computations in MapReduce
The document discusses how to perform common matrix computations like matrix-vector multiplication (Ax), computing matrix norms (||Ax||), and factorizations like QR and SVD on tall-and-skinny matrices using MapReduce. Key strategies include distributing computations across mappers, using partial local computations to reduce communication costs, and combining results across reducers. Computing BTA is more expensive than ATA due to the need to communicate all matrix rows.
The document describes a Python module called r.ipso that is used in GRASS GIS to generate ipsographic and ipsometric curves from raster elevation data. The module imports GRASS and NumPy libraries, reads elevation and cell count statistics from a raster, calculates normalized elevation and area values, and uses these to plot the curves and output quantile information. The module demonstrates calling GRASS functionality from Python scripts.
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014PyData
Pythran is a an ahead of time compiler that turns modules written in a large subset of Python into C++ meta-programs that can be compiled into efficient native modules. It targets mainly compute intensive part of the code, hence it comes as no surprise that it focuses on scientific applications that makes extensive use of Numpy. Under the hood, Pythran inter-procedurally analyses the program and performs high level optimizations and parallel code generation. Parallelism can be found implicitly in Python intrinsics or Numpy operations, or explicitly specified by the programmer using OpenMP directives directly in the Python source code. Either way, the input code remains fully compatible with the Python interpreter. While the idea is similar to Parakeet or Numba, the approach differs significantly: the code generation is not performed at runtime but offline. Pythran generates C++11 heavily templated code that makes use of the NT2 meta-programming library and relies on any standard-compliant compiler to generate the binary code. We propose to walk through some examples and benchmarks, exposing the current state of what Pythran provides as well as the limit of the approach.
This document discusses various techniques for optimizing Python code, including:
1. Using the right algorithms and data structures to minimize time complexity, such as choosing lists, sets or dictionaries based on needed functionality.
2. Leveraging Python-specific optimizations like string concatenation, lookups, loops and imports.
3. Profiling code with tools like timeit, cProfile and visualizers to identify bottlenecks before optimizing.
4. Optimizing only after validating a performance need and starting with general strategies before rewriting hotspots in Python or other languages. Premature optimization can complicate code.
This document provides an overview of SciPy and demonstrates some of its functionality for interpolation, integration, and optimization. SciPy imports NumPy functions and provides additional tools for domains like signal processing, linear algebra, special functions, and more. Examples show linear, cubic and barycentric interpolation of 1D and 2D functions. Integration tools like quad, dblquad, simps and cumtrapz are applied to functions. However, optimization examples are not shown.
Visualization and Matplotlib using Python.pptxSharmilaMore5
This document provides an overview of Matplotlib, a Python data visualization library. It discusses Matplotlib's pyplot and OO APIs, how to install Matplotlib, create basic plots using functions like plot(), and customize plots using markers and line styles. It also covers displaying plots, the Matplotlib user interface, Matplotlib's relationships with NumPy and Pandas, and examples of different types of graphs and charts like line plots that can be created with Matplotlib.
Being a slow interpreter, Python may drive a system to deliver utmost speed if some guidelines are followed. The key is to treat programming languages as syntactic sugar to the machine code. It expedites the workflow of timing, iterative design, automatic testing, optimization, and realize an HPC system balancing the time to market and quality of code.
Speed is the king. 10x productive developers change business. So does 10x faster code. Python is 100x slower than C++ but it only matters when you really use Python to implement number-crunching algorithms. We should not do that, and instead go directly with C++ for speed. It calls for strict disciplines of software engineering and code quality, but it should be noted that here the quality is defined by the runtime and the time to market.
The presentation focuses on the Python side of the development workflow. It is made possible by confining C++ in architecture defined by the Python code, which realizes most of the software engineering. The room for writing fast C++ code is provided by pybind11 and careful design of typed data objects. The data objects hold memory buffers exposed to Python as numpy ndarrays for direct access for speed.
This document discusses algorithms for drawing 2D graphics primitives like lines, triangles, and circles in computer graphics. It begins by introducing basic concepts like coordinate systems, pixels, and graphics APIs. It then covers algorithms for drawing lines, including the slope-intercept method, DDA algorithm, and Bresenham's line drawing algorithm, which uses only integer calculations for better performance. Finally, it briefly mentions extending these techniques to draw other shapes like circles and curves, as well as filling shapes.
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)Austin Benson
The passage discusses the importance of teaching children about money at a young age through activities like allowing them to make purchases and helping with household financial tasks. Starting financial education early can help children understand money management and make responsible decisions as adults. Children who learn about earning, spending, and saving money tend to continue practicing healthy financial habits into their teenage and adult years.
Swift is proposed as a next-generation platform for TensorFlow that could provide benefits over Python like improved performance, type safety, and enabling automatic differentiation at compile time. However, Python currently dominates the machine learning ecosystem. Swift and Python are intended to have a complementary relationship, with each suited to different use cases. Examples show comparable MNIST implementations in both Swift and Python for TensorFlow.
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
To let the world know about our product, we check open-source projects. By the moment we have checked 245 projects. A side effect: we found 9574 errors and notified the authors about them.
1. The document discusses various types of plots that can be created using matplotlib in Python, including line plots, bar graphs, histograms, pie charts, frequency polygons, box plots, and scatter plots.
2. It describes how to customize plots by changing colors, styles, widths, and adding labels, titles, and legends.
3. Examples are provided for creating different plot types like line charts, bar graphs, histograms, and customizing aspects of the plots.
Matplotlib is a 2D plotting library for Python that can generate publication-quality figures in both hardcopy and interactive formats. The document provides examples of using Matplotlib to plot lines, histograms, pie charts, scatter plots, subplots, and mathematical functions. Additional resources are also listed for learning more about Matplotlib and an example dataset on apple production by variety.
Towards typesafe deep learning in scalaTongfei Chen
Deep learning is predominantly done in Python, a type-unsafe language. Try changing this unfortunate fact by doing it in Scala instead! With expressive types, compile-time typechecking, and awesome DSLs, we present Nexus, a typesafe, expressive and succinct deep learning framework.
Here are the steps to plot the given functions using MATLAB:
1. Plot y = 0.4x + 1.8 for 0 ≤ x ≤ 35 and 0 ≤ y ≤ 3.5:
x = 0:35;
y = 0.4.*x + 1.8;
plot(x,y)
xlim([0 35])
ylim([0 3.5])
2. Plot imaginary vs real parts of 0.2 + 0.8i*n for 0 ≤ n ≤ 20:
n = 0:20;
z = 0.2 + 0.8i*n;
plot(real(z),imag(z))
xlabel('Real Part')
Why Data Visualization?
What is Data Visualization?
What is matplotlib?
Types of charts
Basic of matplotlib
Bar chart,
Histogram
Pie chart
Scatter chart
Stack plot
Subplot
References
adding extra feature to all types of chart like Bar chart, Histogram, Stack plot
Use the Matplotlib, Luke @ PyCon Taiwan 2012Wen-Wei Liao
Matplotlib is a Python 2D plotting library that produces publication-quality figures in both hardcopy and interactive environments across platforms. It provides both object-oriented and MATLAB-style state machine interfaces. Matplotlib can be used to create simple plots with just a few commands or customize plots extensively by manipulating the object properties of figures, axes, and artists.
Tall-and-skinny Matrix Computations in MapReduce (ICME MR 2013)Austin Benson
Tall-and-skinny Matrix Computations in MapReduce
The document discusses how to perform common matrix computations like matrix-vector multiplication (Ax), computing matrix norms (||Ax||), and factorizations like QR and SVD on tall-and-skinny matrices using MapReduce. Key strategies include distributing computations across mappers, using partial local computations to reduce communication costs, and combining results across reducers. Computing BTA is more expensive than ATA due to the need to communicate all matrix rows.
The document describes a Python module called r.ipso that is used in GRASS GIS to generate ipsographic and ipsometric curves from raster elevation data. The module imports GRASS and NumPy libraries, reads elevation and cell count statistics from a raster, calculates normalized elevation and area values, and uses these to plot the curves and output quantile information. The module demonstrates calling GRASS functionality from Python scripts.
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014PyData
Pythran is a an ahead of time compiler that turns modules written in a large subset of Python into C++ meta-programs that can be compiled into efficient native modules. It targets mainly compute intensive part of the code, hence it comes as no surprise that it focuses on scientific applications that makes extensive use of Numpy. Under the hood, Pythran inter-procedurally analyses the program and performs high level optimizations and parallel code generation. Parallelism can be found implicitly in Python intrinsics or Numpy operations, or explicitly specified by the programmer using OpenMP directives directly in the Python source code. Either way, the input code remains fully compatible with the Python interpreter. While the idea is similar to Parakeet or Numba, the approach differs significantly: the code generation is not performed at runtime but offline. Pythran generates C++11 heavily templated code that makes use of the NT2 meta-programming library and relies on any standard-compliant compiler to generate the binary code. We propose to walk through some examples and benchmarks, exposing the current state of what Pythran provides as well as the limit of the approach.
This document discusses various techniques for optimizing Python code, including:
1. Using the right algorithms and data structures to minimize time complexity, such as choosing lists, sets or dictionaries based on needed functionality.
2. Leveraging Python-specific optimizations like string concatenation, lookups, loops and imports.
3. Profiling code with tools like timeit, cProfile and visualizers to identify bottlenecks before optimizing.
4. Optimizing only after validating a performance need and starting with general strategies before rewriting hotspots in Python or other languages. Premature optimization can complicate code.
This document provides an overview of SciPy and demonstrates some of its functionality for interpolation, integration, and optimization. SciPy imports NumPy functions and provides additional tools for domains like signal processing, linear algebra, special functions, and more. Examples show linear, cubic and barycentric interpolation of 1D and 2D functions. Integration tools like quad, dblquad, simps and cumtrapz are applied to functions. However, optimization examples are not shown.
Visualization and Matplotlib using Python.pptxSharmilaMore5
This document provides an overview of Matplotlib, a Python data visualization library. It discusses Matplotlib's pyplot and OO APIs, how to install Matplotlib, create basic plots using functions like plot(), and customize plots using markers and line styles. It also covers displaying plots, the Matplotlib user interface, Matplotlib's relationships with NumPy and Pandas, and examples of different types of graphs and charts like line plots that can be created with Matplotlib.
Being a slow interpreter, Python may drive a system to deliver utmost speed if some guidelines are followed. The key is to treat programming languages as syntactic sugar to the machine code. It expedites the workflow of timing, iterative design, automatic testing, optimization, and realize an HPC system balancing the time to market and quality of code.
Speed is the king. 10x productive developers change business. So does 10x faster code. Python is 100x slower than C++ but it only matters when you really use Python to implement number-crunching algorithms. We should not do that, and instead go directly with C++ for speed. It calls for strict disciplines of software engineering and code quality, but it should be noted that here the quality is defined by the runtime and the time to market.
The presentation focuses on the Python side of the development workflow. It is made possible by confining C++ in architecture defined by the Python code, which realizes most of the software engineering. The room for writing fast C++ code is provided by pybind11 and careful design of typed data objects. The data objects hold memory buffers exposed to Python as numpy ndarrays for direct access for speed.
This document discusses algorithms for drawing 2D graphics primitives like lines, triangles, and circles in computer graphics. It begins by introducing basic concepts like coordinate systems, pixels, and graphics APIs. It then covers algorithms for drawing lines, including the slope-intercept method, DDA algorithm, and Bresenham's line drawing algorithm, which uses only integer calculations for better performance. Finally, it briefly mentions extending these techniques to draw other shapes like circles and curves, as well as filling shapes.
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)Austin Benson
The passage discusses the importance of teaching children about money at a young age through activities like allowing them to make purchases and helping with household financial tasks. Starting financial education early can help children understand money management and make responsible decisions as adults. Children who learn about earning, spending, and saving money tend to continue practicing healthy financial habits into their teenage and adult years.
Swift is proposed as a next-generation platform for TensorFlow that could provide benefits over Python like improved performance, type safety, and enabling automatic differentiation at compile time. However, Python currently dominates the machine learning ecosystem. Swift and Python are intended to have a complementary relationship, with each suited to different use cases. Examples show comparable MNIST implementations in both Swift and Python for TensorFlow.
Welcome to MIND UP: a special presentation for Cloudvirga, a Stewart Title company. In this session, we’ll explore how you can “mind up” and unlock your potential by using generative AI chatbot tools at work.
Curious about the rise of AI chatbots? Unsure how to use them-or how to use them safely and effectively in your workplace? You’re not alone. This presentation will walk you through the practical benefits of generative AI chatbots, highlight best practices for safe and responsible use, and show how these tools can help boost your productivity, streamline tasks, and enhance your workday.
Whether you’re new to AI or looking to take your skills to the next level, you’ll find actionable insights to help you and your team make the most of these powerful tools-while keeping security, compliance, and employee well-being front and center.
Deepfake Phishing: A New Frontier in Cyber ThreatsRaviKumar256934
n today’s hyper-connected digital world, cybercriminals continue to develop increasingly sophisticated methods of deception. Among these, deepfake phishing represents a chilling evolution—a combination of artificial intelligence and social engineering used to exploit trust and compromise security.
Deepfake technology, once a novelty used in entertainment, has quickly found its way into the toolkit of cybercriminals. It allows for the creation of hyper-realistic synthetic media, including images, audio, and videos. When paired with phishing strategies, deepfakes can become powerful weapons of fraud, impersonation, and manipulation.
This document explores the phenomenon of deepfake phishing, detailing how it works, why it’s dangerous, and how individuals and organizations can defend themselves against this emerging threat.
Newly poured concrete opposing hot and windy conditions is considerably susceptible to plastic shrinkage cracking. Crack-free concrete structures are essential in ensuring high level of durability and functionality as cracks allow harmful instances or water to penetrate in the concrete resulting in structural damages, e.g. reinforcement corrosion or pressure application on the crack sides due to water freezing effect. Among other factors influencing plastic shrinkage, an important one is the concrete surface humidity evaporation rate. The evaporation rate is currently calculated in practice by using a quite complex Nomograph, a process rather tedious, time consuming and prone to inaccuracies. In response to such limitations, three analytical models for estimating the evaporation rate are developed and evaluated in this paper on the basis of the ACI 305R-10 Nomograph for “Hot Weather Concreting”. In this direction, several methods and techniques are employed including curve fitting via Genetic Algorithm optimization and Artificial Neural Networks techniques. The models are developed and tested upon datasets from two different countries and compared to the results of a previous similar study. The outcomes of this study indicate that such models can effectively re-develop the Nomograph output and estimate the concrete evaporation rate with high accuracy compared to typical curve-fitting statistical models or models from the literature. Among the proposed methods, the optimization via Genetic Algorithms, individually applied at each estimation process step, provides the best fitting result.
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...Jimmy Lai
Managing tech debt in large legacy codebases isn’t just a challenge—it’s an ongoing battle that can drain developer productivity and morale. In this talk, I’ll introduce a Python-powered Tech Debt Framework bar-raiser designed to help teams tackle even the most daunting tech debt problems with 100,000+ violations. This open-source framework empowers developers and engineering leaders by: - Tracking Progress: Measure and visualize the state of tech debt and trends over time. - Recognizing Contributions: Celebrate developer efforts and foster accountability with contribution leaderboards and automated shoutouts. - Automating Fixes: Save countless hours with codemods that address repetitive debt patterns, allowing developers to focus on higher-priority work.
Through real-world case studies, I’ll showcase how we: - Reduced 70,000+ pyright-ignore annotations to boost type-checking coverage from 60% to 99.5%. - Converted a monolithic sync codebase to async, addressing blocking IO issues and adopting asyncio effectively.
Attendees will gain actionable strategies for scaling Python automation, fostering team buy-in, and systematically reducing tech debt across massive codebases. Whether you’re dealing with type errors, legacy dependencies, or async transitions, this talk provides a roadmap for creating cleaner, more maintainable code at scale.
This research is oriented towards exploring mode-wise corridor level travel-time estimation using Machine learning techniques such as Artificial Neural Network (ANN) and Support Vector Machine (SVM). Authors have considered buses (equipped with in-vehicle GPS) as the probe vehicles and attempted to calculate the travel-time of other modes such as cars along a stretch of arterial roads. The proposed study considers various influential factors that affect travel time such as road geometry, traffic parameters, location information from the GPS receiver and other spatiotemporal parameters that affect the travel-time. The study used a segment modeling method for segregating the data based on identified bus stop locations. A k-fold cross-validation technique was used for determining the optimum model parameters to be used in the ANN and SVM models. The developed models were tested on a study corridor of 59.48 km stretch in Mumbai, India. The data for this study were collected for a period of five days (Monday-Friday) during the morning peak period (from 8.00 am to 11.00 am). Evaluation scores such as MAPE (mean absolute percentage error), MAD (mean absolute deviation) and RMSE (root mean square error) were used for testing the performance of the models. The MAPE values for ANN and SVM models are 11.65 and 10.78 respectively. The developed model is further statistically validated using the Kolmogorov-Smirnov test. The results obtained from these tests proved that the proposed model is statistically valid.
The main purpose of the current study was to formulate an empirical expression for predicting the axial compression capacity and axial strain of concrete-filled plastic tubular specimens (CFPT) using the artificial neural network (ANN). A total of seventy-two experimental test data of CFPT and unconfined concrete were used for training, testing, and validating the ANN models. The ANN axial strength and strain predictions were compared with the experimental data and predictions from several existing strength models for fiber-reinforced polymer (FRP)-confined concrete. Five statistical indices were used to determine the performance of all models considered in the present study. The statistical evaluation showed that the ANN model was more effective and precise than the other models in predicting the compressive strength, with 2.8% AA error, and strain at peak stress, with 6.58% AA error, of concrete-filled plastic tube tested under axial compression load. Similar lower values were obtained for the NRMSE index.
2. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Overview
– Anatomy of a figure
●
Figures and axes
– 2D plotting
●
Standard line plotting
●
Other plotting + text annotation
– 3D plotting
●
3D axes + 3D line/surface plotting
– Other plotting
●
Contours + image visualization
3. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Matplotlib
– Mathematical plotting library
– Python extension for graphics
●
Suited for visualization of data and creation of high-quality figures
●
Extensive package for 2D plotting, and add-on toolkits for 3D plotting
●
Pyplot: MATLAB-like procedural interface to the object-oriented API
– Import convention
from matplotlib import pyplot as plt
import matplotlib.pyplot as plt
5. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
A simple plot
– Syntax is array-based
– If not interactive, also write:
In [1]: x = np.linspace(0, 2.0*np.pi, 100)
In [2]: cx, sx = np.cos(x), np.sin(x)
In [3]: plt.plot(x, cx)
...: plt.plot(x, sx)
...: plt.show()
8. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Anatomy
– Hierarchical structure
– Figure
●
The overall window on which everything is drawn
●
Components: one or more axes, suptitle, ...
plt.figure(num=None, figure index, 1-based
figsize=None, (width, height) in inches
dpi=None, resolution
facecolor=None, background color
...)
9. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Anatomy
– Axes
●
The area on which the data is plotted
● Belongs to a figure, placed arbitrarily (axes) or in grid (subplot)
●
Components: x/y-axis, ticks, spines, labels, title, legend, ...
●
All methods of active axes are directly callable via Pyplot interface
plt.axes((left, bottom, width, height), **kwargs)
plt.subplot(nrows, ncols, index, **kwargs)
**kwargs: facecolor=None, polar=False, ...
10. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Anatomy
– Axes components
● Get or set limits: plt.xlim, plt.ylim, plt.axis
– left, right = plt.xlim()
– plt.xlim(left, right)
– plt.axis((left, right, bottom, top)), plt.axis('equal')
● Get or set ticks: plt.xticks, plt.yticks
– locs, labels = plt.xticks()
– plt.xticks(np.arange(3), ('a', 'b', 'c'))
● Set labels: plt.xlabel(txt), plt.ylabel(txt)
● Set title: plt.title(txt)
● Others: plt.box(), plt.grid(), ...
12. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
2D plotting
– Standard line plotting: basic syntax
●
Connect data points (x, y) with optional format string
● Color (c): b, g, r, c, m, y, k, w
● Linestyle (l): -, --, -., :
● Marker (m): o, *, ., +, x, s, d, ^, <, >, p, h, ...
plt.plot(y)
plt.plot(x, y)
plt.plot(x, y, 'clm')
13. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
2D plotting
– Standard line plotting: advanced syntax
– Multiple plots per axes possible
– Legend:
plt.plot(x, y, **kwargs)
**kwargs: color, linestyle, linewidth, marker,
markeredgecolor, markeredgewidth,
markerfacecolor, markersize, label, ...
plt.legend(('a', 'b', 'c'), loc='upper right')
14. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
2D plotting
– For full plot details, check out plt.plot?
– Example
In [1]: t = np.arange(0.0, 2.0, 0.01)
...: s = 1.0 + np.sin(2.0*np.pi*t)
In [2]: plt.axes(facecolor='silver')
...: plt.plot(t, s, 'r')
...: plt.xlabel('time (s)')
...: plt.ylabel('voltage (mV)')
...: plt.title('About as simple as it gets')
...: plt.grid()
15. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
2D plotting
– Plotting methods are actually connected to axes
●
Pyplot provides an interface to the active axes
In [1]: t = np.arange(0.0, 2.0, 0.01)
...: s = 1.0 + np.sin(2.0*np.pi*t)
In [2]: ax = plt.axes()
...: ax.plot(t, s, 'r')
...: ax.set(facecolor='silver',
...: xlabel='time (s)',
...: ylabel='voltage (mV)',
...: title='About as simple as it gets')
...: ax.grid()
16. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
2D plotting
– Example: data statistics
●
Data in the file “populations.txt” describes the populations of
hares, lynxes and carrots in northern Canada during 20 years
●
Load the data and plot it
●
Compute the mean populations over time
●
Which species has the highest population each year?
# year hare lynx carrot
1900 30e3 4e3 48300
1901 47.2e3 6.1e3 48200
1902 70.2e3 9.8e3 41500
...
17. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
2D plotting
– Example: data statistics
●
Load the data and plot it
In [1]: data = np.loadtxt('populations.txt')
In [2]: year, hares, lynxes, carrots = data.T
In [3]: plt.axes((0.2, 0.1, 0.6, 0.8))
...: plt.plot(year, hares)
...: plt.plot(year, lynxes)
...: plt.plot(year, carrots)
...: plt.xticks(np.arange(1900, 1921, 5))
...: plt.yticks(np.arange(1, 9) * 10000)
...: plt.legend(('Hare', 'Lynx', 'Carrot'))
18. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
2D plotting
– Example: data statistics
●
Compute the mean populations over time
●
Which species has the highest population each year?
In [4]: populations = data[:, 1:]
In [5]: populations.mean(axis=0)
Out[5]: array([34080.9524, 20166.6667, 42400.])
In [6]: populations.std(axis=0)
Out[6]: array([20897.9065, 16254.5915, 3322.5062])
In [7]: populations.argmax(axis=1)
Out[7]: array([2, 2, 0, 0, 1, 1, 2, 2, 2, 2, ...])
21. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
2D plotting
– Text
● Axes text: plt.title(txt), plt.xlabel(txt), plt.ylabel(txt)
● Plain text: plt.text(x, y, txt)
● Annotation: plt.annotate(txt, xy=(x, y), xytext=(xt, yt),
arrowprops={'arrowstyle':'->'})
●
Extensive math rendering engine
– Support for TeX markup inside dollar signs ($)
– Use raw strings (precede the quotes with an 'r')
plt.title('alpha > beta') # normal text
plt.title(r'$alpha > beta$') # math text
23. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
3D plotting
– Module mplot3d
●
This toolkit adds simple 3D plotting to matplotlib with same “look-and-feel”
●
It supplies an axes object that can create a 2D projection of a 3D scene
– Creation of 3D axes object
● Use ax = mplot3d.Axes3D(fig)
●
Use any standard axes creation method
with keyword projection='3d'
– ax = plt.subplot(111, projection='3d')
from mpl_toolkits import mplot3d
25. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
3D plotting
– Natural plot extensions
● Line plots: ax.plot(x, y, z), ax.plot3D(x, y, z)
● Scatter plots: ax.scatter(x, y, z), ax.scatter3D(x, y, z)
In [1]: theta = np.linspace(-4*np.pi, 4*np.pi, 100)
...: z = np.linspace(-2, 2, 100)
...: r = z**2 + 1
...: x = r * np.sin(theta)
...: y = r * np.cos(theta)
In [2]: ax = plt.axes(projection='3d')
...: ax.plot(x, y, z, 'r')
...: ax.set(title='parametric curve')
26. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
3D plotting
– Surface plotting
● Wireframe plot: ax.plot_wireframe(X, Y, Z)
● Surface plot: ax.plot_surface(X, Y, Z)
– Surface options
●
Create coordinate matrices from coordinate vectors
– X, Y = np.meshgrid(x, y, sparse=False, copy=True)
●
Color maps: mapping between numeric values and colors
– Use keyword cmap
– Manipulated via module matplotlib.cm
– Examples: jet, hot, coolwarm, bone, ...
27. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
3D plotting
– Example
In [1]: x = np.arange(-5, 5, 0.25)
...: y = np.arange(-5, 5, 0.25)
...: X, Y = np.meshgrid(x, y)
...: R = np.sqrt(X**2 + Y**2)
...: Z = np.sin(R)
In [2]: plt.figure(figsize=(10, 4))
...: plt.suptitle('surface plots')
...: ax1 = plt.subplot(1, 2, 1, projection='3d')
...: ax1.plot_wireframe(X, Y, Z, color='black')
...: ax2 = plt.subplot(1, 2, 2, projection='3d')
...: ax2.plot_surface(X, Y, Z, cmap='coolwarm')
28. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Contour plotting
– Contour lines: basic syntax
– Other contour functions:
● Filled contours: plt.contourf(X, Y, Z, levels)
● Contour identification: plt.clabel(cs), plt.colorbar(cs)
● 3D contour lines (mplot3d): ax.contour(X, Y, Z, levels)
plt.contour(Z)
plt.contour(X, Y, Z)
plt.contour(X, Y, Z, levels)
29. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Contour plotting
– Example
In [1]: t = np.arange(-2, 2, 0.01)
...: X, Y = np.meshgrid(t, t)
...: Z = np.sin(X * np.pi / 2)
...: + np.cos(Y * np.pi / 4)
In [2]: plt.figure(figsize=(10, 4))
...: plt.subplot(1, 2, 1)
...: cs = plt.contour(X, Y, Z)
...: plt.clabel(cs)
...: plt.subplot(1, 2, 2)
...: cs = plt.contourf(X, Y, Z, cmap='coolwarm')
...: plt.colorbar(cs)
30. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Image plotting
– Image
●
A matrix of color intensities (via color map)
●
A matrix of RGB or RGBA colors (3D array of dept = 3 or 4)
– Image plots: basic syntax
– Other matrix visualization:
● Matrix values: plt.matshow(A)
● Matrix sparsity: plt.spy(A)
plt.imshow(img)
31. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Image plotting
– Example
In [1]: A = np.diag(np.arange(10, 21))
In [2]: plt.figure(figsize=(10, 4))
...: plt.subplot(2, 1, 1)
...: plt.imshow(A, cmap='summer')
...: plt.subplot(2, 1, 2)
...: plt.spy(A, marker='*')
32. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Image plotting
– Example: Mandelbrot set
●
Fractal set of complex numbers
● Definition: any c for which zi+1
= zi
2
+ c does
not diverge, starting from z0
= 0
● Property: limi→∞
sup | zi+1
| ≤ 2 for any valid c
In [1]: def mandelbrot(nx, ny, max_it=20):
...: # TODO
...: return M
In [2]: M = mandelbrot(501, 501, 50)
...: plt.imshow(M.T, cmap='flag')
...: plt.axis('off')
33. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Image plotting
– Example: Mandelbrot set
In [1]: def mandelbrot(nx, ny, max_it=20):
...: x = np.linspace(-2.0, 1.0, nx)
...: y = np.linspace(-1.5, 1.5, ny)
...: C = x[:,np.newaxis]
...: + 1.0j*y[np.newaxis,:]
...: Z = C.copy()
...: M = np.ones((nx, ny), dtype=bool)
...: for i in range(max_it):
...: Z[M] = Z[M]**2 + C[M]
...: M[np.abs(Z) > 2] = False
...: return M
34. Lab Calc
2024-2025
Matplotlib: Python Plotting
●
Colors
– Predefined colors
●
abbreviation: b, g, r, c, m, y, k, w
●
full name: blue, green, red, cyan, magenta, yellow, black, white, ...
– RGB/RGBA code
●
tuple of three or four float values in [0, 1]
●
a hexadecimal RGB or RGBA string
– Black and white
●
string representation of a float value in [0, 1]
– All string specifications of color are case-insensitive