|
79 | 79 | " if ax is None:\n", |
80 | 80 | " fig, ax = plt.subplots()\n", |
81 | 81 | " for n, _traj in enumerate(data):\n", |
82 | | - " ax.hist(_traj, bins=30, alpha=.33, density=True, color='C{}'.format(n));\n", |
83 | | - " ylims = ax.get_ylim()\n", |
| 82 | + " h, e = np.histogram(_traj, bins=30, density=True)\n", |
| 83 | + " ax.fill_between(e[1:], h, step='pre', alpha=.33, color='C{}'.format(n))\n", |
| 84 | + " \n", |
| 85 | + " ylims = (0, ax.get_ylim()[1])\n", |
84 | 86 | " xlims = ax.get_xlim()\n", |
85 | 87 | " for n, _traj in enumerate(data):\n", |
86 | 88 | " ax.plot(\n", |
|
98 | 100 | " ax.text(0.86 * xlims[1], 0.5 * ylims[1], '$x(time)$', ha='left', va='center', rotation=90)\n", |
99 | 101 | " ax.set_xlabel('TICA coordinate')\n", |
100 | 102 | " ax.set_ylabel('histogram counts & trajectory time')\n", |
| 103 | + " ax.set_ylim(0, ax.get_ylim()[1]) # fill_between resets lower ylim < 0\n", |
101 | 104 | " ax.legend(loc=2)" |
102 | 105 | ] |
103 | 106 | }, |
|
905 | 908 | "name": "python", |
906 | 909 | "nbconvert_exporter": "python", |
907 | 910 | "pygments_lexer": "ipython3", |
908 | | - "version": "3.6.5" |
| 911 | + "version": "3.6.6" |
909 | 912 | }, |
910 | 913 | "toc": { |
911 | 914 | "base_numbering": 1, |
|
0 commit comments