PyAutoFEP icon indicating copy to clipboard operation
PyAutoFEP copied to clipboard

analyze_results.py fails with matplotlib==2.2.3

Open luancarvalhomartins opened this issue 3 years ago • 2 comments

When using matplotlib 2.2.3 py37hb69df0a_0, analyze_results.py fails with

All available analysis will be run
================== Pairwise ΔΔG ==================
         Perturbation           protein    water  
[...]/anaconda3/envs/pyautofep_temp/lib/python3.7/site-packages/matplotlib/tight_layout.py:228: UserWarning: tight_layout : falling back to Agg renderer
  warnings.warn("tight_layout : falling back to Agg renderer")
Traceback (most recent call last):
  File "[...]/PyAutoFEP/analyze_results.py", line 1645, in <module>
    ddg_data_result = [analyze_perturbation(**each_kwargs) for each_kwargs in arguments_data_holder.values()]
  File "[...]/PyAutoFEP/analyze_results.py", line 1645, in <listcomp>
    ddg_data_result = [analyze_perturbation(**each_kwargs) for each_kwargs in arguments_data_holder.values()]
  File "[...]/PyAutoFEP/analyze_results.py", line 935, in analyze_perturbation
    verbosity=verbosity)
  File "[...]/PyAutoFEP/analyze_results.py", line 788, in plot_stacked_bars
    ticks=numpy.arange(0, n_rep) + 0.5)
  File "[...]/anaconda3/envs/pyautofep_temp/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2320, in colorbar
    ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
  File "[...]/anaconda3/envs/pyautofep_temp/lib/python3.7/site-packages/matplotlib/figure.py", line 2098, in colorbar
    cb = cbar.colorbar_factory(cax, mappable, **cb_kw)
  File "[...]/anaconda3/envs/pyautofep_temp/lib/python3.7/site-packages/matplotlib/colorbar.py", line 1399, in colorbar_factory
    cb = Colorbar(cax, mappable, **kwargs)
  File "[...]/anaconda3/envs/pyautofep_temp/lib/python3.7/site-packages/matplotlib/colorbar.py", line 920, in __init__
    mappable.autoscale_None()
  File "[...]/anaconda3/envs/pyautofep_temp/lib/python3.7/site-packages/matplotlib/cm.py", line 362, in autoscale_None
    raise TypeError('You must first set_array for mappable')
TypeError: You must first set_array for mappable

It works with matplotlib 3.4.2 py37h06a4308_0.

luancarvalhomartins avatar Nov 12 '21 14:11 luancarvalhomartins

Thank you for your quick check.

When I use python 3.6, the latest version of matplotlib is 3.3.4 installed. Then I found that I get an error when I run the following command.

python ../../generate_perturbation_map.py --map_type=star --map_bias=FXR_12 --input lig_data/*.mol

Traceback (most recent call last):

File "../../generate_perturbation_map.py", line 635, in matplotlib.use('svg') AttributeError: module 'matplotlib' has no attribute 'use'

To get around this, I installed 2.2.3.

It might be better to use python version 3.7.

baba-hashimoto avatar Nov 12 '21 15:11 baba-hashimoto

I test with python 3.6 and it worked:

python                    3.6.13               h12debd9_1
matplotlib                3.3.4            py36h06a4308_0  
matplotlib-base           3.3.4            py36h62a2d02_0 

Which is in line with the matplotlib documentation that suggests that matplotlib.use is available in 3.3.4 (https://matplotlib.org/3.3.4/api/matplotlib_configuration_api.html#matplotlib.use)

What I tested so far:

matplotlib==2.2.3 python==3.7.11 -> error
matplotlib==3.3.4 python==3.6.13 -> works
matplotlib==3.3.4 python==3.7.11 -> works
matplotlib==3.4.2 python==3.7.11 -> works

luancarvalhomartins avatar Nov 12 '21 18:11 luancarvalhomartins

matplotlib 2.2 is now ~5 years old and 3.X series is the main development branch for a while. I am closing this one.

luancarvalhomartins avatar Apr 07 '23 14:04 luancarvalhomartins