Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError: local variable 'fig' referenced before assignment #122

Open
xushanthu-2014 opened this issue Sep 2, 2023 · 0 comments

Comments

@xushanthu-2014
Copy link

The error happens when I ran the code:

    import matplotlib.pyplot as plt
    fig = plt.figure(figsize=(25, 7))
    ax1 = fig.add_subplot(111, projection='polar')
    ax2 = fig.add_subplot(121, projection='polar')
    
    # plot BRDF and phase function
    plot1 = SRF.polarplot(inc = list(np.linspace(0,85,5)), multip = 1.5, legpos = (0.,0.5), polarax=ax2,
                         label='Surface scattering phase function', legend=True)
    plot2 = V.polarplot(inc = list(np.linspace(0,120,5)) ,multip = 1.5, legpos = (0.0,0.5), polarax=ax1,
                         label='Volume scattering phase function', legend=True)
    
    fig.tight_layout()

in the example: https://github.com/TUW-GEO/rt1/blob/master/doc/examples/example_lin_comb.ipynb.
The error information is:

Traceback (most recent call last):

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/spyder_kernels/py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "/Users/xushan/research/TUD/vodca/demo_rt1.py", line 120, in <module>
    plot1 = SRF.polarplot(inc = list(np.linspace(0,85,5)), multip = 1.5, legpos = (0.,0.5), polarax=ax1,

  File "/Users/xushan/opt/anaconda3/envs/py310/lib/python3.10/site-packages/rt1/rtplots.py", line 263, in polarplot
    return fig

UnboundLocalError: local variable 'fig' referenced before assignment

It seems that the fig is not explicitly assigned in the function rtplots.py if polarax is not None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant