<tfoot id='HFR8B'></tfoot>
    <i id='HFR8B'><tr id='HFR8B'><dt id='HFR8B'><q id='HFR8B'><span id='HFR8B'><b id='HFR8B'><form id='HFR8B'><ins id='HFR8B'></ins><ul id='HFR8B'></ul><sub id='HFR8B'></sub></form><legend id='HFR8B'></legend><bdo id='HFR8B'><pre id='HFR8B'><center id='HFR8B'></center></pre></bdo></b><th id='HFR8B'></th></span></q></dt></tr></i><div id='HFR8B'><tfoot id='HFR8B'></tfoot><dl id='HFR8B'><fieldset id='HFR8B'></fieldset></dl></div>

    <small id='HFR8B'></small><noframes id='HFR8B'>

      <bdo id='HFR8B'></bdo><ul id='HFR8B'></ul>
  1. <legend id='HFR8B'><style id='HFR8B'><dir id='HFR8B'><q id='HFR8B'></q></dir></style></legend>

    1. 使用 Matplotlib 绘制时间戳(小时/分钟/秒)

      时间:2023-09-14
      <tfoot id='3FeNG'></tfoot>
      <i id='3FeNG'><tr id='3FeNG'><dt id='3FeNG'><q id='3FeNG'><span id='3FeNG'><b id='3FeNG'><form id='3FeNG'><ins id='3FeNG'></ins><ul id='3FeNG'></ul><sub id='3FeNG'></sub></form><legend id='3FeNG'></legend><bdo id='3FeNG'><pre id='3FeNG'><center id='3FeNG'></center></pre></bdo></b><th id='3FeNG'></th></span></q></dt></tr></i><div id='3FeNG'><tfoot id='3FeNG'></tfoot><dl id='3FeNG'><fieldset id='3FeNG'></fieldset></dl></div>
        <tbody id='3FeNG'></tbody>
      <legend id='3FeNG'><style id='3FeNG'><dir id='3FeNG'><q id='3FeNG'></q></dir></style></legend>

          • <bdo id='3FeNG'></bdo><ul id='3FeNG'></ul>
          • <small id='3FeNG'></small><noframes id='3FeNG'>

                本文介绍了使用 Matplotlib 绘制时间戳(小时/分钟/秒)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我想绘制一些时间戳(年-月-日时-分-秒格式).我正在使用以下代码,但它没有显示任何小时-分钟-秒信息,它将它们显示为 00-00-00.我仔细检查了我的日期数组,从下面的代码片段可以看出,它们不为零.

                I want to plot some timestamps (Year-month-day Hour-Minute-Second format). I am using the following code, however it doesn't show any hour-minute-second information, it shows them as 00-00-00. I double checked my date array, and as you can see from the snippet below, they are not zero.

                你知道我为什么会得到 00-00-00 的任何想法吗?

                Do you have any idea about why I am getting 00-00-00's?

                import matplotlib.pyplot as plt
                import matplotlib.dates as md
                import dateutil
                
                dates = [dateutil.parser.parse(s) for s in datestrings]
                # datestrings = ['2012-02-21 11:28:17.980000', '2012-02-21 12:15:32.453000', '2012-02-21 23:26:23.734000', '2012-02-26 17:42:15.804000']
                plt.subplots_adjust(bottom=0.2)
                plt.xticks( rotation= 80 )
                ax=plt.gca()
                xfmt = md.DateFormatter('%Y-%m-%d %H:%M:%S')
                ax.xaxis.set_major_formatter(xfmt)
                plt.plot(dates[0:10],plt_data[0:10], "o-")
                plt.show()
                

                推荐答案

                尝试放大图表,您会看到日期时间随着 x 轴比例的变化而扩大.

                Try zooming in on your graph, you will see the datetimes expand as your x axis scale changes.

                在 matplotlib 中绘制 unix 时间戳

                在尝试绘制染色体上正选择的热图时,我遇到了类似的烦人问题.如果我缩小得太远,事情就会完全消失!

                I had a similarly annoying problem when trying to plot heatmaps of positive selection on chromosomes. If I zoomed out too far things would disappear entirely!

                此代码完全按照您提供的日期绘制日期,但不会在两者之间添加刻度.

                edit: This code plots your dates exactly as you give them, but doesn't add ticks in between.

                import matplotlib.pyplot as plt
                import matplotlib.dates as md
                import dateutil
                
                datestrings = ['2012-02-21 11:28:17.980000', '2012-02-21 12:15:32.453000', '2012-02-21 23:26:23.734000', '2012-02-26 17:42:15.804000']
                dates = [dateutil.parser.parse(s) for s in datestrings]
                
                plt_data = range(5,9)
                plt.subplots_adjust(bottom=0.2)
                plt.xticks( rotation=25 )
                
                ax=plt.gca()
                ax.set_xticks(dates)
                
                xfmt = md.DateFormatter('%Y-%m-%d %H:%M:%S')
                ax.xaxis.set_major_formatter(xfmt)
                plt.plot(dates,plt_data, "o-")
                plt.show()
                

                这篇关于使用 Matplotlib 绘制时间戳(小时/分钟/秒)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Python pandas 通过 dt 访问器有效地将日期时间转换 下一篇:平台 localtime()/gmtime() 函数的时间戳超出范围

                相关文章

                最新文章

                <small id='QmROk'></small><noframes id='QmROk'>

                • <bdo id='QmROk'></bdo><ul id='QmROk'></ul>
              • <legend id='QmROk'><style id='QmROk'><dir id='QmROk'><q id='QmROk'></q></dir></style></legend>

                  <i id='QmROk'><tr id='QmROk'><dt id='QmROk'><q id='QmROk'><span id='QmROk'><b id='QmROk'><form id='QmROk'><ins id='QmROk'></ins><ul id='QmROk'></ul><sub id='QmROk'></sub></form><legend id='QmROk'></legend><bdo id='QmROk'><pre id='QmROk'><center id='QmROk'></center></pre></bdo></b><th id='QmROk'></th></span></q></dt></tr></i><div id='QmROk'><tfoot id='QmROk'></tfoot><dl id='QmROk'><fieldset id='QmROk'></fieldset></dl></div>
                1. <tfoot id='QmROk'></tfoot>