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

      <legend id='63ju4'><style id='63ju4'><dir id='63ju4'><q id='63ju4'></q></dir></style></legend>

          <bdo id='63ju4'></bdo><ul id='63ju4'></ul>
      1. <tfoot id='63ju4'></tfoot>
      2. 如何在Matplotlib中将图例置于情节之外

        How to put the legend outside the plot in Matplotlib(如何在Matplotlib中将图例置于情节之外)
            <bdo id='XFpOo'></bdo><ul id='XFpOo'></ul>

              <tbody id='XFpOo'></tbody>

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

                  <i id='XFpOo'><tr id='XFpOo'><dt id='XFpOo'><q id='XFpOo'><span id='XFpOo'><b id='XFpOo'><form id='XFpOo'><ins id='XFpOo'></ins><ul id='XFpOo'></ul><sub id='XFpOo'></sub></form><legend id='XFpOo'></legend><bdo id='XFpOo'><pre id='XFpOo'><center id='XFpOo'></center></pre></bdo></b><th id='XFpOo'></th></span></q></dt></tr></i><div id='XFpOo'><tfoot id='XFpOo'></tfoot><dl id='XFpOo'><fieldset id='XFpOo'></fieldset></dl></div>
                1. <tfoot id='XFpOo'></tfoot>
                  <legend id='XFpOo'><style id='XFpOo'><dir id='XFpOo'><q id='XFpOo'></q></dir></style></legend>
                  本文介绍了如何在Matplotlib中将图例置于情节之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一系列的20个情节(不是子情节)要在一个图形中制作。我想让传奇走出框框。同时,我不想改变轴,因为图形的尺寸变小了。请为我解答以下问题:

                  1. 我想将图例框保留在绘图区之外。(我希望图例位于绘图区的右侧)。
                  2. 是否一定要减小图例框内文本的字体大小,以便图例框的大小变小。

                  推荐答案

                  • 您可以通过指定FontPropertiesset_size来缩小图例文本。
                  • 资源:
                    • Legend guide
                    • matplotlib.legend
                    • matplotlib.pyplot.legend
                    • matplotlib.font_manager
                      • set_size(self, size)
                      • 有效字体大小为xx-小、x-小、小、中、大、x-大、xx-大、大、小、无
                    • Real Python: Python Plotting With Matplotlib (Guide)
                  import matplotlib.pyplot as plt
                  from matplotlib.font_manager import FontProperties
                  
                  fontP = FontProperties()
                  fontP.set_size('xx-small')
                  
                  p1, = plt.plot([1, 2, 3], label='Line 1')
                  p2, = plt.plot([3, 2, 1], label='Line 2')
                  plt.legend(handles=[p1, p2], title='title', bbox_to_anchor=(1.05, 1), loc='upper left', prop=fontP)
                  

                  • 如Mateen Ulhaq所述,fontsize='xx-small'也有效,无需导入FontProperties
                  plt.legend(handles=[p1, p2], title='title', bbox_to_anchor=(1.05, 1), loc='upper left', fontsize='xx-small')
                  

                  这篇关于如何在Matplotlib中将图例置于情节之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                    <bdo id='2rQVQ'></bdo><ul id='2rQVQ'></ul>
                      <legend id='2rQVQ'><style id='2rQVQ'><dir id='2rQVQ'><q id='2rQVQ'></q></dir></style></legend>
                      • <tfoot id='2rQVQ'></tfoot>

                        <small id='2rQVQ'></small><noframes id='2rQVQ'>

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