Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Pandas
  • Seaborn
  • Matplotlib
  • Altair
  • Bokeh
  • Data Analysis
  • R
  • Machine Learning Math
  • Machin Learning
  • Deep Learning
  • Deep Learning Projects
  • NLP
  • Computer vision
  • Data science
  • Deep learning interview question
  • Machin Learning Interview question
Open In App
Next Article:
Carpet Contour Plot using Plotly in Python
Next article icon

Carpet Contour Plot using Plotly in Python

Last Updated : 01 Oct, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library.

Carpet Contour Plot

A carpet contour plot is a graphical technique for representing a 3-dimensional surface by plotting constant z slices, called contours, on a 2-dimensional format. X and Y attributes are used to set the x and y coordinates. In case the value of x is missing then it will form a cheater plot. A and B attributes should be used to save the values of the parameter.

Syntax: plotly.graph_objects.Contourcarpet( a=None,b=None,xaxis=None, yaxis=None, z=None)

Parameters:

NameDescription
aSets the x coordinates.
bSets the y coordinates.
xaxisSets a reference between this trace’s x coordinates and a 2D cartesian x axis. If “x” (the default value), the x coordinates refer to layout.xaxis. If “x2”, the x coordinates refer to layout.xaxis2
yaxis Sets a reference between this trace’s y coordinates and a 2D cartesian y axis. If “y” (the default value), the y coordinates refer to layout.yaxis. If “y2”, the y coordinates refer to layout.yaxis2
zSets the z data.

Example:

Python3
import plotly.graph_objects as go  fig = go.Figure(go.Carpet(     a=[1, 2, 3, 4, 5, 6],     b=[6, 5, 4, 3, 2, 1],     y=[1, 2, 3, 4, 5, 6],      aaxis=dict(         tickprefix='F = ',         ticksuffix='N',         smoothing=0.2,         minorgridcount=10,     ),     baxis=dict(         tickprefix='P = ',         ticksuffix='pa',         smoothing=0.4,         minorgridcount=9,     ) ))  fig.show() 

Output:

Adding Contours

In plotly, contours can be added by using the go.Contourcarpet() method of graph_object class. Contours should be added in such a way that the graph body should be in the proper segment.

Example:

Python3
import plotly.graph_objects as go  fig = go.Figure()  fig.add_trace(go.Contourcarpet(     a = [1, 2, 3, 4, 5, 6],     b = [6, 5, 4, 3, 2, 1],     z = [1, 1.96, 5, 6.1028, 4, 5.0625],     autocontour = False,     contours = dict(         start = 1,         end = 14,         size = 1     ),     line = dict(         width = 2,         smoothing = 0     ),     colorbar = dict(        len = 0.4,         y = 0.25     ) ))   fig.add_trace(go.Carpet(     a=[1, 2, 3, 4, 5, 6],     b=[6, 5, 4, 3, 2, 1],     y=[1, 2, 3, 4, 5, 6],      aaxis=dict(         tickprefix='F = ',         ticksuffix='N',         smoothing=0.2,         minorgridcount=10,     ),     baxis=dict(         tickprefix='P = ',         ticksuffix='pa',         smoothing=0.4,         minorgridcount=9,     ) ))  fig.show() 

Output:


Next Article
Carpet Contour Plot using Plotly in Python

N

nishantsundriyal98
Improve
Article Tags :
  • Python
  • Python-Plotly
Practice Tags :
  • python

Similar Reads

    Carpet Plots using Plotly in Python
    A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. Plotly is an interactive visualization libra
    3 min read
    Ternary contours Plot using Plotly in Python
    A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization libra
    3 min read
    Contour Plot using Matplotlib - Python
    Contour plots also called level plots are a tool for doing multivariate analysis and visualizing 3-D plots in 2-D space. If we consider X and Y as our variables we want to plot then the response Z will be plotted as slices on the X-Y plane due to which contours are sometimes referred as Z-slices or
    2 min read
    3D Cone Plots using Plotly in Python
    Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library
    2 min read
    3D Contour Plotting in Python using Matplotlib
    Matplotlib was introduced keeping in mind, only two-dimensional plotting. But at the time when the release of 1.0 occurred, the 3d utilities were developed upon the 2d and thus, we have 3d implementation of data available today! The 3d plots are enabled by importing the mplot3d toolkit. Let's look a
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences