1

How can one make an circular arrow flow chart with three chevrons (or arrows) in python similar to the figure shown below? figure

C R
  • 2,182
  • 5
  • 32
  • 41

1 Answers1

3

It turns out that matplotlib has a module Sankey that will allow one to create a circular arrow flow chart. The python code to do this is as follows:

import matplotlib.pyplot as plt
from matplotlib.sankey import Sankey

fontsize= 20
def circle(filename):
    color = 'w'
    pos = [2, 1]
    fig = plt.figure(figsize=(8, 9))
    ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[], frameon=False)
    sankey = Sankey(ax=ax, gap=0.5, scale=1.0/pos[0])

    sankey.add(patchlabel='\nFirst', facecolor='darkslateblue',
               flows=[pos[1], -pos[1]],
               labels=[None, None],
               pathlengths=[0.5, 0.25],
               orientations=[-1, -1], connect=(1, 0))
    sankey.add(patchlabel='\n\n\n\n\n\nSecond', facecolor='blueviolet',
               flows=[pos[1], -pos[1]],
               labels=[None, None],
               pathlengths=[0.5, 0.25],
               orientations=[0, -1], prior = 0, connect=(1, 0))
    sankey.add( facecolor='cornflowerblue',
                flows=[pos[1], -pos[1]],
                labels=[None, None],
                pathlengths=[0.22, 0.75],
                orientations=[0, -1], prior = 1, connect=(1, 0))


    add_horizontal_text(ax, color)
    diagrams = sankey.finish()
    for diagram in diagrams:
        diagram.text.set_fontweight('bold')
        diagram.text.set_fontsize(fontsize)
        diagram.text.set_color(color)

    diagrams[1].text.set_fontsize(fontsize-2)
    plt.savefig(filename)

    return

def add_horizontal_text(ax, color):
    x = -0.5
    y = -1.68
    offset = .1
    ax.text(x, y, 'Third', fontsize=fontsize, weight='bold', ha='center', color=color)
    return

circle('CircularArrow.png')
C R
  • 2,182
  • 5
  • 32
  • 41