SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Ted To <rai...@th...> - 2015年06月17日 14:13:14
Attachments: figure_1.png
Hi,
I'm having a strange problem and I don't understand why this is
happening. I am plotting the dataframe in: http://pastebin.com/C0Pt0iYd
but I'm getting too few tick marks. My code for the plot is:
 fig, ax = plt.subplots()
 plt.rc('text', usetex=True)
 fig.autofmt_xdate()
 ax.plot(indices.carli,'b-',label=r'\textsf{Carli}')
 ax.plot(indices.geomean,'g-',label=r'\textsf{GeoMean}')
 ax.plot(indices.laspeyres,'c-',label=r'\textsf{Laspeyres}')
 ax.plot(indices.paasche,'m-',label=r'\textsf{Paasche}')
 ax.plot(indices.tornqvist,'y-',label=r'\textsf{T\"ornqvist}')
 plt.xlabel(r'\textsf{Month}')
 plt.ylabel(r'\textsf{Index value}')
 ax.set_xticklabels(indices.index)
Any ideas what I'm doing wrong?
Thanks,
Ted
From: Benjamin R. <ben...@ou...> - 2015年06月17日 14:29:16
Why are you calling ax.set_xticklabels()?. Why not pass the x values to
ax.plot() along with the y values? Then you won't need to set the labels
because matplotlib will do it for you.
Ben Root
On Wed, Jun 17, 2015 at 10:13 AM, Ted To <rai...@th...> wrote:
> Hi,
>
> I'm having a strange problem and I don't understand why this is
> happening. I am plotting the dataframe in: http://pastebin.com/C0Pt0iYd
> but I'm getting too few tick marks. My code for the plot is:
>
> fig, ax = plt.subplots()
> plt.rc('text', usetex=True)
> fig.autofmt_xdate()
> ax.plot(indices.carli,'b-',label=r'\textsf{Carli}')
> ax.plot(indices.geomean,'g-',label=r'\textsf{GeoMean}')
> ax.plot(indices.laspeyres,'c-',label=r'\textsf{Laspeyres}')
> ax.plot(indices.paasche,'m-',label=r'\textsf{Paasche}')
> ax.plot(indices.tornqvist,'y-',label=r'\textsf{T\"ornqvist}')
> plt.xlabel(r'\textsf{Month}')
> plt.ylabel(r'\textsf{Index value}')
> ax.set_xticklabels(indices.index)
>
> Any ideas what I'm doing wrong?
>
> Thanks,
> Ted
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Ted To <rai...@th...> - 2015年06月17日 16:49:03
Unless I recall incorrectly, I think I am using set_xticklabels because 
indices.index are strings. When I tried specifying 
ax.plot(indices.index,indices.carli) I get a ValueError.
Ted
On 2015年06月17日 10:28 am, Benjamin Root wrote:
> Why are you calling ax.set_xticklabels()?. Why not pass the x values
> to ax.plot() along with the y values? Then you won't need to set the
> labels because matplotlib will do it for you.
> 
> Ben Root
> 
> On Wed, Jun 17, 2015 at 10:13 AM, Ted To <rai...@th...> wrote:
> 
>> Hi,
>> 
>> I'm having a strange problem and I don't understand why this is
>> happening. I am plotting the dataframe in:
>> http://pastebin.com/C0Pt0iYd [1]
>> but I'm getting too few tick marks. My code for the plot is:
>> 
>> fig, ax = plt.subplots()
>> plt.rc('text', usetex=True)
>> fig.autofmt_xdate()
>> ax.plot(indices.carli,'b-',label=r'textsf{Carli}')
>> ax.plot(indices.geomean,'g-',label=r'textsf{GeoMean}')
>> ax.plot(indices.laspeyres,'c-',label=r'textsf{Laspeyres}')
>> ax.plot(indices.paasche,'m-',label=r'textsf{Paasche}')
>> ax.plot(indices.tornqvist,'y-',label=r'textsf{T"ornqvist}')
>> plt.xlabel(r'textsf{Month}')
>> plt.ylabel(r'textsf{Index value}')
>> ax.set_xticklabels(indices.index)
>> 
>> Any ideas what I'm doing wrong?
>> 
>> Thanks,
>> Ted
>> 
>> 
> ------------------------------------------------------------------------------
>> 
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users [2]
> 
> 
> 
> Links:
> ------
> [1] http://pastebin.com/C0Pt0iYd
> [2] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Benjamin R. <ben...@ou...> - 2015年06月17日 16:56:25
Then convert them to date objects? Also, I am guessing that the length of
indices.index is not the same as indices.carli, which could also be the
reason for a ValueError. So you would need to use whatever pandas variable
that indices.index derived from.
Ben Root
On Wed, Jun 17, 2015 at 12:48 PM, Ted To <rai...@th...> wrote:
> Unless I recall incorrectly, I think I am using set_xticklabels because
> indices.index are strings. When I tried specifying
> ax.plot(indices.index,indices.carli) I get a ValueError.
>
> Ted
>
>
> On 2015年06月17日 10:28 am, Benjamin Root wrote:
>
>> Why are you calling ax.set_xticklabels()?. Why not pass the x values
>> to ax.plot() along with the y values? Then you won't need to set the
>> labels because matplotlib will do it for you.
>>
>> Ben Root
>>
>> On Wed, Jun 17, 2015 at 10:13 AM, Ted To <rai...@th...> wrote:
>>
>> Hi,
>>>
>>> I'm having a strange problem and I don't understand why this is
>>> happening. I am plotting the dataframe in:
>>> http://pastebin.com/C0Pt0iYd [1]
>>> but I'm getting too few tick marks. My code for the plot is:
>>>
>>> fig, ax = plt.subplots()
>>> plt.rc('text', usetex=True)
>>> fig.autofmt_xdate()
>>> ax.plot(indices.carli,'b-',label=r'textsf{Carli}')
>>> ax.plot(indices.geomean,'g-',label=r'textsf{GeoMean}')
>>> ax.plot(indices.laspeyres,'c-',label=r'textsf{Laspeyres}')
>>> ax.plot(indices.paasche,'m-',label=r'textsf{Paasche}')
>>> ax.plot(indices.tornqvist,'y-',label=r'textsf{T"ornqvist}')
>>> plt.xlabel(r'textsf{Month}')
>>> plt.ylabel(r'textsf{Index value}')
>>> ax.set_xticklabels(indices.index)
>>>
>>> Any ideas what I'm doing wrong?
>>>
>>> Thanks,
>>> Ted
>>>
>>>
>>>
>> ------------------------------------------------------------------------------
>>
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users [2]
>>>
>>
>>
>>
>> Links:
>> ------
>> [1] http://pastebin.com/C0Pt0iYd
>> [2] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
From: Ted To <rai...@th...> - 2015年06月17日 19:11:50
Thank you, that worked. And also showed me why the xticks were 
mismatched -- apparently my index was not sorted.
On 2015年06月17日 12:55 pm, Benjamin Root wrote:
> Then convert them to date objects? Also, I am guessing that the length
> of indices.index is not the same as indices.carli, which could also be
> the reason for a ValueError. So you would need to use whatever pandas
> variable that indices.index derived from.
> 
> Ben Root
> 
> On Wed, Jun 17, 2015 at 12:48 PM, Ted To <rai...@th...> wrote:
> 
>> Unless I recall incorrectly, I think I am using set_xticklabels
>> because indices.index are strings. When I tried specifying
>> ax.plot(indices.index,indices.carli) I get a ValueError.
>> 
>> Ted
>> 
>> On 2015年06月17日 10:28 am, Benjamin Root wrote:
>> Why are you calling ax.set_xticklabels()?. Why not pass the x
>> values
>> to ax.plot() along with the y values? Then you won't need to set
>> the
>> labels because matplotlib will do it for you.
>> 
>> Ben Root
>> 
>> On Wed, Jun 17, 2015 at 10:13 AM, Ted To <rai...@th...>
>> wrote:
>> 
>> Hi,
>> 
>> I'm having a strange problem and I don't understand why this is
>> happening. I am plotting the dataframe in:
>> http://pastebin.com/C0Pt0iYd [1] [1]
>> but I'm getting too few tick marks. My code for the plot is:
>> 
>> fig, ax = plt.subplots()
>> plt.rc('text', usetex=True)
>> fig.autofmt_xdate()
>> ax.plot(indices.carli,'b-',label=r'textsf{Carli}')
>> ax.plot(indices.geomean,'g-',label=r'textsf{GeoMean}')
>> ax.plot(indices.laspeyres,'c-',label=r'textsf{Laspeyres}')
>> ax.plot(indices.paasche,'m-',label=r'textsf{Paasche}')
>> ax.plot(indices.tornqvist,'y-',label=r'textsf{T"ornqvist}')
>> plt.xlabel(r'textsf{Month}')
>> plt.ylabel(r'textsf{Index value}')
>> ax.set_xticklabels(indices.index)
>> 
>> Any ideas what I'm doing wrong?
>> 
>> Thanks,
>> Ted
>> 
>> 
> ------------------------------------------------------------------------------
>> 
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users [2]
>> [2]
>> 
>> Links:
>> ------
>> [1] http://pastebin.com/C0Pt0iYd [1]
>> [2] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> [2]
> 
> 
> 
> Links:
> ------
> [1] http://pastebin.com/C0Pt0iYd
> [2] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /