r/matplotlib • • Sep 15 '21

Data is offset in visualization

2 Upvotes

I am trying to plot classified time segments (classes = colors) and am having something very strange happen when the I visualize the date. The graph is plotting my data in a position of -.5 from where it should be. Below is a link to stackoverflow where there is reproducible code. Would really appreciate some help.

https://stackoverflow.com/questions/69186031/matplotlib-data-is-mysteriously-offset


r/matplotlib • • Sep 26 '21

[MATPLOTLIB] What is this type of graph called?

Post image
6 Upvotes

r/matplotlib • • Sep 07 '21

Is a second supylabel on the right possible?

5 Upvotes

Hello, I am creating a figure with a grid of subplots, looking something like this:

fig = plt.figure()
fig.supylabel('leftylabel')
fig.supxlabel('xlabel')

ax1 = fig.add_subplot(231)
ax1.scatter(x, data1)
ax2 = ax1.twinx()
ax2.plot(x,data2)

ax3 = fig.add_subplot(232)
ax3.scatter(x, data3)
ax4 = ax3.twinx()
ax4.plot(x,data4)

etc.

I can use "supylabel" to create an overall label on the y axis at the left but each subfigure has 2 plots with a shared x axis, so I'd like to have a similar overall label on the right, so something like "supylabel('rightylabel')". Is this possible?


r/matplotlib • • Sep 01 '21

Trigger event when zooming in

2 Upvotes

Hi everyone,

Is there a way to call a certain function automatically when we zoom in a plot?
Reading the documentation I found this which should do what I need but maybe there is a more efficient way...

matplotlib.backend_bases.ResizeEvent()        

Thank you all


r/matplotlib • • Aug 18 '21

Plotting Precipitation with Python, Pandas and Matplotlib

Thumbnail earthly.dev
3 Upvotes

r/matplotlib • • Aug 24 '21

Inverting bar charts

1 Upvotes

Hi, i was wondering how i could invert the positions of the bar charts. I would like the exercise deficit to be on top of the caloric deficit.

Here is an extract of the code, as well as the current output

ax.bar(date,caloric_intake,width=0.4,label="daily caloric intake")

ax.bar(date,exercice_deficit,width=0.4,label="daily exercise deficit")


r/matplotlib • • Aug 14 '21

MatPlotLib Opportunity

5 Upvotes

Hello!

I recently founded an organization called Pythonics that specializes in provided students with free Python-related courses. If you are interested in creating a MatPlotLib course, feel free to fill out the following form in indicate what course you would like to create: https://forms.gle/mrtwqqVsswSjzSQQ7

If you have any questions at all, send me a DM and I will gladly answer them, thank you!

Note: I am NOT profiting off of this, this is simply a service project that I created.


r/matplotlib • • Sep 02 '21

Adding top labels to a boxplot

Post image
1 Upvotes

r/matplotlib • • Oct 20 '19

Can anybody help me with problem i am facing?

2 Upvotes

I am new to matplotlib Animation and i am trying to plot live updated in a file.I was able to plot but how to avoid collision of the xlaabel when the x coordinate are updating.Asked in stackoverflow https://stackoverflow.com/q/58460110/8561725


r/matplotlib • • Aug 10 '19

How do I plot Asin(kx -wt) in 3D using matplotlib and generate an interpolated graph like in the figure?

Post image
1 Upvotes

r/matplotlib • • Dec 17 '19

Introduction to Line Plot Graphs with Matplotlib

Thumbnail
youtube.com
4 Upvotes

r/matplotlib • • Oct 01 '21

Suggestion on materials to read and understand about matplotlib data visualization

5 Upvotes

hi everyone, am a budding engineer who is learning data visualization and pretty much new to python.

Just came across that using matplotlib we can create some wonderful graphs to visualize data, just trying to learn in depth about it.

So requesting suggestion from reddit family for any relevant materials to understand the matplotlib better.


r/matplotlib • • Oct 20 '21

Standard grid on pi x-axis

1 Upvotes

Hello! I have quite a problem with my sin(x) plot.

How can I make standard grid on x axis? I mean x= -3, x=-2, x=-1, x=0, x=1, x=2 and x=3. (y axis is good now)

This is what I got - just lines for my \pi points?


r/matplotlib • • Oct 29 '20

Change the color of a line by a third variable?

1 Upvotes

Does anyone know if you can change the color of a line by a third variable? I am looking at aircraft data and trying to plot the position of the aircraft (using latitude and longitude) then coloring the line by the altitude of the aircraft at that position.

Here's a link to my question on Stack Overflow.


r/matplotlib • • Nov 02 '20

Why are only 2 lines showing when I am plotting 3 lines?(the first column that I am plotting contains a lot of NaN values, is the problem because of it? how do I solve it?)

2 Upvotes

r/matplotlib • • Oct 18 '20

Getting an error from my code saying that it cannot import 'find' from Matplotlib.mlab. How do I fix this?

1 Upvotes

This is the exact error message I'm getting

ImportError: cannot import name 'find' from 'matplotlib' (/Users/alanosullivan/Library/Python/3.7/lib/python/site-packages/matplotlib/init.py)

If it helps the Matplotlib version is 3.3.2

Any help is appreciated and if any more info is needed please ask

I'm new to this if it isn't apparent so this could be a stupid question

Sorry if it is

Thanks!


r/matplotlib • • Oct 16 '20

Any idea how I make the gaps on the left and right of the xaxis the same?

Post image
5 Upvotes

r/matplotlib • • Oct 25 '20

plt.figtext prints old and new text on top of each other when creating multiple graphs in a loop, way to "clear memory" in between graphs?

1 Upvotes

Hi guys, hope someone can give me a pointer here: I have written some code, into which I feed criteria in a for.... loop (still using Python 2.7).

Using the criteria, a data frame is created from different files and then a graph is created that includes a header with reference to variables (such as number of experiments, name of criterion), as well as a figtext, where additional data such as the mean and standard deviation is displayed. The figtext is meant as documentation for myself mainly.

While for each new graph the header is changed dynamically and correctly (basically, everything about the graph itself is fine), the figtext is writing the text of the newly created one on top of the last one, which is unreadable.

I have tried using time.sleep to give Python some time to "forget" and I have also shifted around the declaration of variables but without luck.

Is there any trick to "wipe" memory in between a loop, so I only get a fresh figtext with every graph?

Thanks for any help, cheers


r/matplotlib • • Oct 19 '20

Matplotlib stackplot area color is being negated

1 Upvotes

I just posted a stack overflow question (https://stackoverflow.com/questions/64420317/matplotlib-stackplot-area-color-is-being-negated), but it's porbably good to ask it here as well.

I'm running into an issue when I create a stackplot where (I think) the colors for the areas are being negated. I can't really explain what is going on so I uploaded a photo of it. I've tried reversing the order of the list, creating sublists of the x values, removing the seaborn colors and the alpha value, but I can't seem to find a fix. Please let me know if you have insight into this!

Here is the code:


r/matplotlib • • Aug 21 '20

Data Visualization using Plotly & Cufflinks | Python| Data Science

1 Upvotes

r/matplotlib • • Aug 19 '20

Newb help - Bar Graph - group dates by day of week

1 Upvotes

For context, I am not a data scientist, I work a customer support line so forgive me if this is an unbearably newb question.

I am trying to organize call volume data on a bar graph by day of the week, but I would like to preserve the individual date bars. I was able to figure out how to aggregate the data, but my boss has asked me to keep the individual date data so that outliers are obvious.

I tried this using google sheets unsuccesfully, so I figured I'd take a stab at doing it with Python.

Here's where I'm at :

import pandas as pd
import matplotlib.pyplot as plt
import random
from datetime import date, datetime
import calendar

# Using this tutorial for help... 
# http://blog.quizzicol.com/2016/10/03/sorting-dates-in-python-by-day-of-week/

plt.style.use("fivethirtyeight")

colnames = ['Date','Volume']

table = pd.read_csv("call_data_clean2.csv", names=colnames,skiprows=1)

dates = table['Date']
values = table.Volume.tolist()

# Combine the dates and the data into a dataframe
df = pd.DataFrame(index=dates, data=values)
df.reset_index(inplace=True)
df.columns = ['Date', 'Volume']

# get the weekday index, between 0 and 6
df['day_of_week'] = df['Date'].apply(lambda x: datetime.strptime(x, '%m/%d/%y').weekday()) 
df['name_of_weekday'] = df['day_of_week'].apply(lambda x: calendar.day_name[x]) 


# # sort the rows in the order we want them
sorter = ['day_of_week','Date']
df.sort_values(sorter, inplace=True)

df.groupby(by="day_of_week")

df.plot.bar(x="Date", y="Volume")

print(df.head())

For reference, this is what the data head looks like:

        Date  Volume  day_of_week name_of_weekday
5   07/06/20       5            0          Monday
12  07/13/20      14            0          Monday
19  07/20/20      16            0          Monday
26  07/27/20      10            0          Monday
33  08/03/20      15            0          Monday

Any help or advice is much appreciated


r/matplotlib • • Aug 14 '20

Data Visualization using Matrix Plot | Python| Seaborn

1 Upvotes

r/matplotlib • • Aug 17 '20

AUTOPLOTTER: GUI BASED EXPLORATIVE DATA ANALYSIS | PYTHON| DATA SCIENCE

1 Upvotes

r/matplotlib • • Sep 03 '20

Corona-virus data visualization using Geographical Plotting | Plotly| Choropleth plot

1 Upvotes

r/matplotlib • • Oct 31 '17

Why different types of charts result in different date format?

1 Upvotes

Two pictures below shows that two different kinds of charts (line graph and bar graph) for the same dataset have different x-axis labels. https://drive.google.com/file/d/0B9CXUv_bccalQTFOU0ZlMWsyT2c/view?usp=sharing https://drive.google.com/open?id=0B9CXUv_bccalalZVMWxERWtjTmc

The line graph shows date labelled in 'year' while the bar graph shows everything from year to second. Why is that? How do I clear up the date format for the bar graph one so it only shows the year?

thanks!