Answers for "adjust text python"

0

adjust text python

mtcars = pd.read_csv('../../figures/mtcars.csv')
def plot_mtcars(adjust=False, *args, **kwargs):
    plt.figure(figsize=(9, 6))
    plt.scatter(mtcars['wt'], mtcars['mpg'], s=15, c='r', edgecolors=(1,1,1,0))
    texts = []
    for x, y, s in zip(mtcars['wt'], mtcars['mpg'], mtcars['Car']):
        texts.append(plt.text(x, y, s, size=9))
    plt.xlabel('wt')
    plt.ylabel('mpg')
    if adjust:
        plt.title('%s iterations' % adjust_text(texts, arrowprops=dict(arrowstyle="-", color='k', lw=0.5),
                                                save_steps=False, save_prefix='/home/ilya/adjustText/examples/mtcars', **kwargs))
    else:
        plt.title('Original')
plot_mtcars()
Posted by: Guest on September-10-2021
0

adjust text python

mtcars = pd.read_csv('../../figures/mtcars.csv')
def plot_mtcars(adjust=False, *args, **kwargs):
    plt.figure(figsize=(9, 6))
    plt.scatter(mtcars['wt'], mtcars['mpg'], s=15, c='r', edgecolors=(1,1,1,0))
    texts = []
    for x, y, s in zip(mtcars['wt'], mtcars['mpg'], mtcars['Car']):
        texts.append(plt.text(x, y, s, size=9))
    plt.xlabel('wt')
    plt.ylabel('mpg')
    if adjust:
        plt.title('%s iterations' % adjust_text(texts, arrowprops=dict(arrowstyle="-", color='k', lw=0.5),
                                                save_steps=False, save_prefix='/home/ilya/adjustText/examples/mtcars', **kwargs))
    else:
        plt.title('Original')
plot_mtcars()
Posted by: Guest on September-10-2021

Python Answers by Framework

Browse Popular Code Answers by Language