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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현