Presenting ticks for every plotted pointsLimiting floats to two decimal pointsPlot logarithmic axes with matplotlib in pythonHow to change the font size on a matplotlib plotHow to put the legend out of the plotMatplotlib make tick labels font size smallerreducing number of plot ticksWhen to use cla(), clf() or close() for clearing a plot in matplotlib?Save plot to image file instead of displaying it using MatplotlibChanging the “tick frequency” on x or y axis in matplotlib?How to make IPython notebook matplotlib plot inline

Alignment of various blocks in tikz

Like totally amazing interchangeable sister outfits II: The Revenge

How to pronounce 'c++' in Spanish

Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?

Who was the lone kid in the line of people at the lake at the end of Avengers: Endgame?

How can I practically buy stocks?

Does a large simulator bay have standard public address announcements?

Why did some of my point & shoot film photos come back with one third light white or orange?

Rivers without rain

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

Critique of timeline aesthetic

Discriminated by senior researcher because of my ethnicity

Pulling the rope with one hand is as heavy as with two hands?

Dynamic SOQL query relationship with field visibility for Users

Don’t seats that recline flat defeat the purpose of having seatbelts?

Why did C use the -> operator instead of reusing the . operator?

How come there are so many candidates for the 2020 Democratic party presidential nomination?

How to not starve gigantic beasts

Why do games have consumables?

Why does Mind Blank stop the Feeblemind spell?

How to fry ground beef so it is well-browned

How to write a column outside the braces in a matrix?

"Hidden" theta-term in Hamiltonian formulation of Yang-Mills theory

Read line from file and process something



Presenting ticks for every plotted points


Limiting floats to two decimal pointsPlot logarithmic axes with matplotlib in pythonHow to change the font size on a matplotlib plotHow to put the legend out of the plotMatplotlib make tick labels font size smallerreducing number of plot ticksWhen to use cla(), clf() or close() for clearing a plot in matplotlib?Save plot to image file instead of displaying it using MatplotlibChanging the “tick frequency” on x or y axis in matplotlib?How to make IPython notebook matplotlib plot inline






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am new to Python and programming in general.



I am attempting to plot value for every week on a bar chart. I would like to have ticks on the x axis under every plotted point so it is easy to understand the relation between values and dates.



I have a Pandas dataframe(df_clean) that looks like this (sorry for the french column name):



Data columns (total 20 columns):
Statut 23467 non-null object
P.O 23467 non-null object
Fournisseur 23467 non-null object
Date Comm. 23467 non-null object
Date Annul. 23466 non-null object
Date TPA 23467 non-null object
Qté Comm. 23467 non-null float64
Courant comm. 23467 non-null float64
Cout comm. 23467 non-null float64
Qté recue 23467 non-null float64
Courant recue 23467 non-null float64
Cout recue 23467 non-null float64
Qté souff. 23467 non-null float64
Courant souff. 23467 non-null float64
Cout souff. 23467 non-null float64
% recue 23467 non-null float64
% MB 23467 non-null float64
Premier jour sem. TPA 23467 non-null object
Year TPA 23467 non-null int64
Jour de la semaine TPA 23467 non-null object


My goal is to plot the sum of df_clean["Cout comm."] for every df_clean["Premier jour sem. TPA"]. I would like it to look like this:



Desired result



Here is the code up to now



#Group by first day of week
sem_tpa_group = df_clean.groupby("Premier jour sem. TPA").agg("sum")
sem_tpa_group.reset_index(inplace=True)

#Limit the amount of week to show
sem_tpa_group = sem_tpa_group[sem_tpa_group["Premier jour sem. TPA"] > date.today()]

#Create graph
fig = plt.figure()
ax = plt.subplot(111)
plt.plot(sem_tpa_group["Premier jour sem. TPA"], sem_tpa_group["Cout comm."],'o-',label='Ord. cost')
plt.plot(sem_tpa_group["Premier jour sem. TPA"], sem_tpa_group["Cout recue"],'o-',label='Rec. cost')
plt.legend(loc=1)
plt.ylabel('Cost')
plt.xlabel('Week date')
plt.grid()
plt.show()


The result is this:



Result



Would anyone be able to tell me how to get tick information for every plotted point on the x axis?



I tried plt.xticks() without any result though I am not sure I did use it the right way.



Thanks a lot for everything










share|improve this question
























  • Something like plt.xticks(matplotlib.dates.date2num((sem_tpa_group["Premier jour sem. TPA"]))) may work. Hard to tell what units that is in though. In general matplotlib represents dates as flaoting point days since 0000-01-01

    – Jody Klymak
    Mar 22 at 23:29












  • The "desired" plot is very likely produced by df.plot.bar. Pandas bar plots are categorical. Matplotlib bar plots, as well as line plots, are numeric plots. You may still achieve categorical plots with matplotlib by converting your datetime index/column to strings before plotting.

    – ImportanceOfBeingErnest
    Mar 23 at 1:45

















1















I am new to Python and programming in general.



I am attempting to plot value for every week on a bar chart. I would like to have ticks on the x axis under every plotted point so it is easy to understand the relation between values and dates.



I have a Pandas dataframe(df_clean) that looks like this (sorry for the french column name):



Data columns (total 20 columns):
Statut 23467 non-null object
P.O 23467 non-null object
Fournisseur 23467 non-null object
Date Comm. 23467 non-null object
Date Annul. 23466 non-null object
Date TPA 23467 non-null object
Qté Comm. 23467 non-null float64
Courant comm. 23467 non-null float64
Cout comm. 23467 non-null float64
Qté recue 23467 non-null float64
Courant recue 23467 non-null float64
Cout recue 23467 non-null float64
Qté souff. 23467 non-null float64
Courant souff. 23467 non-null float64
Cout souff. 23467 non-null float64
% recue 23467 non-null float64
% MB 23467 non-null float64
Premier jour sem. TPA 23467 non-null object
Year TPA 23467 non-null int64
Jour de la semaine TPA 23467 non-null object


My goal is to plot the sum of df_clean["Cout comm."] for every df_clean["Premier jour sem. TPA"]. I would like it to look like this:



Desired result



Here is the code up to now



#Group by first day of week
sem_tpa_group = df_clean.groupby("Premier jour sem. TPA").agg("sum")
sem_tpa_group.reset_index(inplace=True)

#Limit the amount of week to show
sem_tpa_group = sem_tpa_group[sem_tpa_group["Premier jour sem. TPA"] > date.today()]

#Create graph
fig = plt.figure()
ax = plt.subplot(111)
plt.plot(sem_tpa_group["Premier jour sem. TPA"], sem_tpa_group["Cout comm."],'o-',label='Ord. cost')
plt.plot(sem_tpa_group["Premier jour sem. TPA"], sem_tpa_group["Cout recue"],'o-',label='Rec. cost')
plt.legend(loc=1)
plt.ylabel('Cost')
plt.xlabel('Week date')
plt.grid()
plt.show()


The result is this:



Result



Would anyone be able to tell me how to get tick information for every plotted point on the x axis?



I tried plt.xticks() without any result though I am not sure I did use it the right way.



Thanks a lot for everything










share|improve this question
























  • Something like plt.xticks(matplotlib.dates.date2num((sem_tpa_group["Premier jour sem. TPA"]))) may work. Hard to tell what units that is in though. In general matplotlib represents dates as flaoting point days since 0000-01-01

    – Jody Klymak
    Mar 22 at 23:29












  • The "desired" plot is very likely produced by df.plot.bar. Pandas bar plots are categorical. Matplotlib bar plots, as well as line plots, are numeric plots. You may still achieve categorical plots with matplotlib by converting your datetime index/column to strings before plotting.

    – ImportanceOfBeingErnest
    Mar 23 at 1:45













1












1








1








I am new to Python and programming in general.



I am attempting to plot value for every week on a bar chart. I would like to have ticks on the x axis under every plotted point so it is easy to understand the relation between values and dates.



I have a Pandas dataframe(df_clean) that looks like this (sorry for the french column name):



Data columns (total 20 columns):
Statut 23467 non-null object
P.O 23467 non-null object
Fournisseur 23467 non-null object
Date Comm. 23467 non-null object
Date Annul. 23466 non-null object
Date TPA 23467 non-null object
Qté Comm. 23467 non-null float64
Courant comm. 23467 non-null float64
Cout comm. 23467 non-null float64
Qté recue 23467 non-null float64
Courant recue 23467 non-null float64
Cout recue 23467 non-null float64
Qté souff. 23467 non-null float64
Courant souff. 23467 non-null float64
Cout souff. 23467 non-null float64
% recue 23467 non-null float64
% MB 23467 non-null float64
Premier jour sem. TPA 23467 non-null object
Year TPA 23467 non-null int64
Jour de la semaine TPA 23467 non-null object


My goal is to plot the sum of df_clean["Cout comm."] for every df_clean["Premier jour sem. TPA"]. I would like it to look like this:



Desired result



Here is the code up to now



#Group by first day of week
sem_tpa_group = df_clean.groupby("Premier jour sem. TPA").agg("sum")
sem_tpa_group.reset_index(inplace=True)

#Limit the amount of week to show
sem_tpa_group = sem_tpa_group[sem_tpa_group["Premier jour sem. TPA"] > date.today()]

#Create graph
fig = plt.figure()
ax = plt.subplot(111)
plt.plot(sem_tpa_group["Premier jour sem. TPA"], sem_tpa_group["Cout comm."],'o-',label='Ord. cost')
plt.plot(sem_tpa_group["Premier jour sem. TPA"], sem_tpa_group["Cout recue"],'o-',label='Rec. cost')
plt.legend(loc=1)
plt.ylabel('Cost')
plt.xlabel('Week date')
plt.grid()
plt.show()


The result is this:



Result



Would anyone be able to tell me how to get tick information for every plotted point on the x axis?



I tried plt.xticks() without any result though I am not sure I did use it the right way.



Thanks a lot for everything










share|improve this question
















I am new to Python and programming in general.



I am attempting to plot value for every week on a bar chart. I would like to have ticks on the x axis under every plotted point so it is easy to understand the relation between values and dates.



I have a Pandas dataframe(df_clean) that looks like this (sorry for the french column name):



Data columns (total 20 columns):
Statut 23467 non-null object
P.O 23467 non-null object
Fournisseur 23467 non-null object
Date Comm. 23467 non-null object
Date Annul. 23466 non-null object
Date TPA 23467 non-null object
Qté Comm. 23467 non-null float64
Courant comm. 23467 non-null float64
Cout comm. 23467 non-null float64
Qté recue 23467 non-null float64
Courant recue 23467 non-null float64
Cout recue 23467 non-null float64
Qté souff. 23467 non-null float64
Courant souff. 23467 non-null float64
Cout souff. 23467 non-null float64
% recue 23467 non-null float64
% MB 23467 non-null float64
Premier jour sem. TPA 23467 non-null object
Year TPA 23467 non-null int64
Jour de la semaine TPA 23467 non-null object


My goal is to plot the sum of df_clean["Cout comm."] for every df_clean["Premier jour sem. TPA"]. I would like it to look like this:



Desired result



Here is the code up to now



#Group by first day of week
sem_tpa_group = df_clean.groupby("Premier jour sem. TPA").agg("sum")
sem_tpa_group.reset_index(inplace=True)

#Limit the amount of week to show
sem_tpa_group = sem_tpa_group[sem_tpa_group["Premier jour sem. TPA"] > date.today()]

#Create graph
fig = plt.figure()
ax = plt.subplot(111)
plt.plot(sem_tpa_group["Premier jour sem. TPA"], sem_tpa_group["Cout comm."],'o-',label='Ord. cost')
plt.plot(sem_tpa_group["Premier jour sem. TPA"], sem_tpa_group["Cout recue"],'o-',label='Rec. cost')
plt.legend(loc=1)
plt.ylabel('Cost')
plt.xlabel('Week date')
plt.grid()
plt.show()


The result is this:



Result



Would anyone be able to tell me how to get tick information for every plotted point on the x axis?



I tried plt.xticks() without any result though I am not sure I did use it the right way.



Thanks a lot for everything







python python-3.x matplotlib






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 17:48









Geekfish

1,2611827




1,2611827










asked Mar 22 at 17:28









Etienne RousseauEtienne Rousseau

63




63












  • Something like plt.xticks(matplotlib.dates.date2num((sem_tpa_group["Premier jour sem. TPA"]))) may work. Hard to tell what units that is in though. In general matplotlib represents dates as flaoting point days since 0000-01-01

    – Jody Klymak
    Mar 22 at 23:29












  • The "desired" plot is very likely produced by df.plot.bar. Pandas bar plots are categorical. Matplotlib bar plots, as well as line plots, are numeric plots. You may still achieve categorical plots with matplotlib by converting your datetime index/column to strings before plotting.

    – ImportanceOfBeingErnest
    Mar 23 at 1:45

















  • Something like plt.xticks(matplotlib.dates.date2num((sem_tpa_group["Premier jour sem. TPA"]))) may work. Hard to tell what units that is in though. In general matplotlib represents dates as flaoting point days since 0000-01-01

    – Jody Klymak
    Mar 22 at 23:29












  • The "desired" plot is very likely produced by df.plot.bar. Pandas bar plots are categorical. Matplotlib bar plots, as well as line plots, are numeric plots. You may still achieve categorical plots with matplotlib by converting your datetime index/column to strings before plotting.

    – ImportanceOfBeingErnest
    Mar 23 at 1:45
















Something like plt.xticks(matplotlib.dates.date2num((sem_tpa_group["Premier jour sem. TPA"]))) may work. Hard to tell what units that is in though. In general matplotlib represents dates as flaoting point days since 0000-01-01

– Jody Klymak
Mar 22 at 23:29






Something like plt.xticks(matplotlib.dates.date2num((sem_tpa_group["Premier jour sem. TPA"]))) may work. Hard to tell what units that is in though. In general matplotlib represents dates as flaoting point days since 0000-01-01

– Jody Klymak
Mar 22 at 23:29














The "desired" plot is very likely produced by df.plot.bar. Pandas bar plots are categorical. Matplotlib bar plots, as well as line plots, are numeric plots. You may still achieve categorical plots with matplotlib by converting your datetime index/column to strings before plotting.

– ImportanceOfBeingErnest
Mar 23 at 1:45





The "desired" plot is very likely produced by df.plot.bar. Pandas bar plots are categorical. Matplotlib bar plots, as well as line plots, are numeric plots. You may still achieve categorical plots with matplotlib by converting your datetime index/column to strings before plotting.

– ImportanceOfBeingErnest
Mar 23 at 1:45












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55304921%2fpresenting-ticks-for-every-plotted-points%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55304921%2fpresenting-ticks-for-every-plotted-points%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript