36. Label and widget refactor

Questions and discussion for this lecture live here. Fire away by hitting Reply below :fire:

Hi Sean, just wanted to suggest a tiny improvement.
When we plot axial force at each node, if we select both Fxi and Fxj for intermediate nodes (between 1 and 15 in the example), we get Fxj labels superimposed to Fxi labels. A simple solution could be to nest an if statement under the last elif

        if(labels == 'Fxi'):
            plt.text(xi+dx, yi+dy, label_i, fontsize = font_size, bbox = dict(facecolor='grey', alpha = 0.1))
        elif(labels == 'Fxj'):
            plt.text(xj+dx, yj+dy, label_j, fontsize = font_size, bbox = dict(facecolor='grey', alpha = 0.1))
        elif(labels == 'Fxi & Fxj'):
            plt.text(xi+dx, yi+dy, label_i, fontsize = font_size, bbox = dict(facecolor='grey', alpha = 0.1))
            if(n == len(members)-1):
                plt.text(xj+dx, yj+dy, label_j, fontsize = font_size, bbox = dict(facecolor='grey', alpha = 0.1))

Thanks @Oliviero - nice addition :+1:
Seán

Hi Sean,

how would you include a button to save the last plotted deflection, Axial fore, BMD, SFD. after resizing margin and selecting desired results.

There is a ToggleButton widget you could implement - you can find the details here.

Personally, I usually just include a savefig command at the end of the plotting function that will automatically save the figure as a png every time the function runs. Then no need for an extra button click.

S