1

我想在我的内部创建一个插图fig,放大我的极坐标图的一部分。

我尝试了各种不同的方法,但似乎无法破解使用matplotlib. 我创建情节的代码(来自我的pandas dataframe)如下。我还包括了它产生的情节。

    def plot_polar_chart_new(n, start, df, sales, title):
      HSV_tuples = [(x * 1.0 / n, 0.5, 0.5) for x in range(n)]
      RGB_tuples = map(lambda x: colorsys.hsv_to_rgb(*x), HSV_tuples)
      RGB_normalised = [tuple(n / max(t) for n in t) for t in RGB_tuples]

      figsize=(15, 15)
      fig = mpl.pyplot.figure(figsize=figsize)
      ax = fig.add_subplot(1,1,1, polar=True)
      start = 0
      prev_count = 0

      for i, salesperson in enumerate(sales):
          count, division = (df[salesperson], df.index)
          ax.bar((division - start) * 2 * np.pi / N, height=count, width=2 * np.pi / N, color=RGB_normalised[i], bottom=prev_count, label=salesperson)
          prev_count += count

      ax.set_xticks(np.linspace(0, 2 * np.pi, N, endpoint=False))
      ax.set_xticklabels(range(start, N + start),fontsize=20)
      ax.yaxis.set_tick_params(labelsize=20)
      ax.set_theta_direction(-1)
      ax.set_theta_offset(np.pi / 2.0)
      ax.set_title(title, y=1.1, fontsize=20)
      ax.legend(bbox_to_anchor=(0.9, 1.1), loc=2)    

      mpl.pyplot.show()

为上述代码创建的绘图

我想创建一个绘图插图,它放大 和 之间的部分17绘图02

请帮忙!谢谢

4

0 回答 0