logo
down
shadow

inconsistent plot between matplotlib and seaborn in Python


inconsistent plot between matplotlib and seaborn in Python

Content Index :

inconsistent plot between matplotlib and seaborn in Python
Tag : python , By : Funkwarrior
Date : November 28 2020, 09:01 AM

hope this fix your issue It seems that sns.pointplot simply uses an array of [0...n-1] as x values and then uses the x values that you provide to label the ticks on the x-axis. You can check that by looking at ax.get_xlim() which outputs [-0.5, 4.5]. Therefore, when you provide the actual x values to plt.plot they just seem to be at a wrong position.
I wouldn't say that this is a bug, since seaborn considers the input to pointplot to be categorial (here's the documentation for more info)
import matplotlib
import matplotlib.pylab as plt
import seaborn as sns
import pandas
import numpy as np
sns.set_style("white")

data = pandas.DataFrame({"x": [0.158, 0.209, 0.31, 0.4, 0.519],
                        "y": [0.13, 0.109, 0.129, 0.250, 1.10],
                        "s": [0.05]*5})

plt.figure()
sns.pointplot(x="x", y="y", data=data)
plt.errorbar(np.arange(5), data["y"], yerr=data["s"], color='r')
plt.show()

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to fix matplotlib and seaborn heatmap plot?


Tag : python-3.x , By : Simon Capewell
Date : March 29 2020, 07:55 AM
Does that help Unfortunately you don't show any code for the matplotlib plot. But the solution to get rid of the grid is to use plt.grid(False).

Plot duration in matplotlib / seaborn


Tag : python , By : rusl
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I want to plot the results of a 5K and a 10K run in Python with matplotlib and seaborn. My dataset has a column time that contains a string object in a HH:MM:SS format, like 00:28:50 or 1:17:23, with the race results. I created my plot by calculating the time in seconds, but I prefer the actual time in HH:MM:SS format on the axis for readability. , One thing you could do is to modify the ticks manually:
order=['5K', '10K']
palette = ['#3498db', '#ff0080']
fig, ax = plt.subplots(figsize=(16, 8))
sns.boxplot(ax=ax, data=df, x='time_sec', y='race', hue='sex', order=order, palette=palette, orient='h', linewidth=2.5)

# get the ticks 
ticks = ax.get_xticks()

# convert the ticks to string
ax.set_xticklabels(pd.to_datetime(ticks, unit='s').strftime('%H:%M:%S'))

plt.title('Time in seconds', fontsize=16)

plt.show()

Python matplotlib/seaborn plot bar chart subcategories


Tag : python , By : nabbed
Date : March 29 2020, 07:55 AM
Hope this helps I have a dictionary of dictionaries called data. I want to plot a bar chart so that each of A, B, C, and D have a value for the pos and neg.
%matplotlib inline 
import matplotlib.pyplot as plt
import pandas as pd

data = {'A': {'pos': 289794, 'neg': 515063},
        'B': {'pos': 174790, 'neg': 292551},
        'C': {'pos': 375574, 'neg': 586616},
        'D': {'pos': 14932, 'neg': 8661}}
df = pd.DataFrame(data)
df = df.T
df ['sum'] = df.sum(axis=1)
df.sort_values('sum', ascending=False)[['neg','pos']].plot.bar() 

How can I plot a categorical feature vs categorical values in python using seaborn or matplotlib


Tag : python , By : ranja
Date : March 29 2020, 07:55 AM
With these it helps How can I plot a bar graph for categorical feature containing values male and female to another column containing binary values like 0 and 1 such that x axis contains the male and female whereas y axis contains the number of values of 0 and 1 corresponding to male and female on y axis.
df.unstack().plot.bar(stacked=False)
df.unstack().plot.barh(stacked=False)

Python Matplotlib/Seaborn/Jupyter - Putting bar plot in wrong place?


Tag : python , By : afds
Date : March 29 2020, 07:55 AM
This might help you You see two axes in Jupyter because you create a fresh one with plt.subplots() and pandas also creates another one.
If you need to reuse an existing axe, pass it to plotting method using ax switch:
fig, axe = plt.subplots()
freq.to_frame().T.plot.barh(stacked=True, ax=axe)
axe = freq.to_frame().T.plot.barh(stacked=True)
Related Posts Related QUESTIONS :
  • How to calculate each single element of a numpy array based on conditions
  • How do I change the width of Jupyter notebook's cell's left part?
  • Measure distance between lat/lon coordinates and utm coordinates
  • Installing megam for NLTK on Windows
  • filter dataframe on each value of a samn column have a specific value of another column in Panda\Python
  • Threading with pubsub throwing AssertionError: 'callableObj is not callable' in wxPython
  • Get grouped data from 2 dataframes with condition
  • How can I import all of sklearns regressors
  • How to take all elements except the first k
  • Whats wrong with my iteration list of lists from csv
  • Tensorflow Estimator API save image summary in eval mode
  • How to Pack with PyQt - how to make QFrame/Layout adapt to content
  • How do I get certain Time Range in Python
  • python doubly linked list - insertAfter node
  • Open .h5 file in Python
  • Joining a directory name with a binary file name
  • python, sort list with two arguments in compare function
  • Is it possible to print from Python using non-ANSI colors?
  • Pandas concat historical data using date minus some number of days
  • CV2: Import Error in Python OpenCV
  • Is it possible to do this loop in a one-liner?
  • invalid literal for int() with base 10: - django
  • Why does my code print a value that I have not assigned as yet?
  • the collatz func in automate boring stuff with python
  • How to find all possible combinations of parameters and funtions
  • about backpropagation deep neural network in tensorflow
  • Sort strings in pandas
  • How do access my flask app hosted in docker?
  • Replace the sentence include some text with Python regex
  • Counting the most common element in a 2D List in Python
  • logout a user from the system using a function in python
  • mp4 metadata not found but exists
  • Django: QuerySet with ExpressionWrapper
  • Pandas string search in list of dicts
  • Decryption from RSA encrypted string from sqlite is not the same
  • need of maximum value in int
  • a list of several tuples, how to extract the same of the first two elements in the small tuple in the large tuple
  • Display image of 2D Sinewaves in 3D
  • how to prevent a for loop from overwriting a dictionary?
  • How To Fix: RuntimeError: size mismatch in pyTorch
  • Concatenating two Pandas DataFrames while maintaining index order
  • Why does this not run into an infinite loop?
  • Python Multithreading no current event loop
  • Element Tree - Seaching for specific element value without looping
  • Ignore Nulls in pandas map dictionary
  • How do I get scrap data from web pages using beautifulsoup in python
  • Variable used, golobal or local?
  • I have a regex statement to pull all numbers out of a text file, but it only finds 77 out of the 81 numbers in the file
  • How do I create a dataframe of jobs and companies that includes hyperlinks?
  • Detect if user has clicked the 'maximized' button
  • Does flask_login automatically set the "next" argument?
  • Indents in python 3
  • How to create a pool of threads
  • Pandas giving IndexError on one dataframe but not on another similar dataframe
  • Django Rest Framework - Testing client.login doesn't login user, ret anonymous user
  • Running dag without dag file in airflow
  • Filling across a specified dimension of a numpy array
  • Python populating dataframe in pandas from text files
  • How to interpolate a single ("non-piecewise") cubic spline from a set of data points?
  • Divide 2 integers (leetcode 29) - recursion issue
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com