1

I'd like to create an inset within my fig which is a zoom in on part of my polar plot.

I've tried various different methods but can't seem to crack the correct way to do using matplotlib. My code to create the plot (from my pandas dataframe) is below. I've also included the plot that it produces.

    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()

Plot created for the above code

I'd like to create a plot inset which zooms in on part of the plot between 17 and 02.

Please help! Thanks

nrs90
  • 168
  • 1
  • 3
  • 19
  • Would [Matplotlib inset polar plot](https://stackoverflow.com/questions/7610973/matplotlib-inset-polar-plot) not work? What problem do you face? – ImportanceOfBeingErnest Nov 03 '18 at 15:27
  • 1
    @ImportanceOfBeingErnest I've seen that example but thats not what Im trying to achieve, Im trying to create a zoomed in version of the plot like [this](http://akuederle.com/matplotlib-zoomed-up-inset) – nrs90 Nov 03 '18 at 22:44
  • Sure, so the first step is to create the inset, which is shown in the link I provided. Once you have that you can update the question with the actual problem you are facing. Also, it's not too clear how such zoom should look for a polar plot, so you may want to explain what you're trying to achieve in more detail. – ImportanceOfBeingErnest Nov 03 '18 at 22:47

0 Answers0