def test_defaults(self): fig = plot_vs_time(self.t, self.y, None) ax = fig.get_axes()[0] assert_allclose(ax.get_lines()[0].get_xydata(), np.array([[ 0., 1.], [ 2., 3.], [ 4., 5.], [ 6., 7.], [ 8., 9.]])) assert_allclose(ax.get_lines()[1].get_xydata(), np.array([[ 0., 2.], [ 2., 4.], [ 4., 6.], [ 6., 8.], [ 8., 10.]])) assert_allclose(ax.get_lines()[2].get_xydata(), np.array([[ 0., 3.], [ 2., 5.], [ 4., 7.], [ 6., 9.], [ 8., 11.]])) assert_equal(ax.get_lines()[0].get_label(), '_line0') assert_equal(ax.get_lines()[1].get_label(), '_line1') assert_equal(ax.get_lines()[2].get_label(), '_line2') assert_equal(ax.get_xlabel(), 'Time, t') assert_equal(ax.get_ylabel(), 'y') assert_equal(ax.get_legend(), None)
def test_line_labels(self): fig = plot_vs_time(self.t,self.y, ['a', 'b', 'c']) ax = fig.get_axes()[0] assert_allclose(ax.get_lines()[0].get_xydata(), np.array([[ 0., 1.], [ 2., 3.], [ 4., 5.], [ 6., 7.], [ 8., 9.]])) assert_allclose(ax.get_lines()[1].get_xydata(), np.array([[ 0., 2.], [ 2., 4.], [ 4., 6.], [ 6., 8.], [ 8., 10.]])) assert_allclose(ax.get_lines()[2].get_xydata(), np.array([[ 0., 3.], [ 2., 5.], [ 4., 7.], [ 6., 9.], [ 8., 11.]])) assert_equal(ax.get_lines()[0].get_label(), 'a') assert_equal(ax.get_lines()[1].get_label(), 'b') assert_equal(ax.get_lines()[2].get_label(), 'c') ok_(not ax.get_legend() is None) assert_equal(ax.get_legend().get_title().get_text(), 'Depth interval:')
def test_propdict_fig_prop_figsize(self): fig = plot_vs_time(self.t, self.y, ['a', 'b', 'c'], prop_dict={'fig_prop': { 'figsize': (8, 9) }}) assert_allclose(fig.get_size_inches(), (8, 9))
def test_propdict_has_legend(self): fig = plot_vs_time(self.t, self.y, ['a', 'b', 'c'], prop_dict={'has_legend': False}) ax = fig.get_axes()[0] assert_equal(ax.get_legend(), None)
def test_propdict_legend_prop_title(self): fig = plot_vs_time(self.t, self.y, ['a', 'b', 'c'], prop_dict={'legend_prop': { 'title': 'abc' }}) ax = fig.get_axes()[0] assert_equal(ax.get_legend().get_title().get_text(), 'abc')
def test_propdict_xylabels(self): fig = plot_vs_time(self.t, self.y, ['a', 'b', 'c'], prop_dict={'xlabel':'xxx', 'ylabel':'yyy'}) ax = fig.get_axes()[0] assert_equal(ax.get_xlabel(), 'xxx') assert_equal(ax.get_ylabel(), 'yyy')
def test_prop_dict_styles(self): fig = plot_vs_time(self.t, self.y, ['a', 'b', 'c'], prop_dict={'styles':[{'markersize': 12, 'marker': '^'}, {'markersize': 3, 'marker': 's'}]}) ax = fig.get_axes()[0] line1= ax.get_lines()[0] line2= ax.get_lines()[1] line3= ax.get_lines()[2] assert_equal(line1.get_marker(),'^') assert_equal(line1.get_markersize(),12) assert_equal(line2.get_marker(),'s') assert_equal(line2.get_markersize(),3) assert_equal(line3.get_marker(),'^') assert_equal(line3.get_markersize(),12)
def test_propdict_legend_prop_title(self): fig = plot_vs_time(self.t, self.y, ['a', 'b', 'c'], prop_dict={'legend_prop':{'title':'abc'}}) ax = fig.get_axes()[0] assert_equal(ax.get_legend().get_title().get_text(), 'abc')
def test_propdict_fig_prop_figsize(self): fig = plot_vs_time(self.t, self.y, ['a', 'b', 'c'], prop_dict={'fig_prop':{'figsize':(8,9)}}) assert_allclose(fig.get_size_inches(), (8,9))
por, doc, settle = zhuandyin2012( z=z, t=t, alpha=alpha, p=p, q=q, drn=drn, tpor=tpor, H = H, kv0 = kv0, mv0 = mv0, gamw = 10, ui = 100, nterms = nterms, plot_eigs=plot_eigs) # z, t, alpha = alpha, p=p, q=q, drn=drn,tpor=tpor, nterms=nterms, plot_eigs=plot_eigs) print('z',repr(z)) print('t', repr(t)) print('por',repr(por)) print('doc',repr(doc)) print('set',repr(settle)) x = np.linspace(0,1,11) kv = (1+alpha*x)**p mv = (1+alpha*x)**q # print('x', repr(x)) # print('kv', repr(kv)) # print('mv', repr(mv)) fig=plt.figure() ax= fig.add_subplot('111') ax.plot(kv, x, label='kv', ls='-') ax.plot(mv, x, label='mv', ls='-') ax.legend() ax.invert_yaxis() fig_por=plot_vs_depth(por, z, line_labels=['{0:.3g}'.format(v) for v in tpor], prop_dict={'xlabel': 'Pore Pressure'}) fig_por.get_axes()[0].grid() # fig_por.get_axes()[0].set_xlim(0,1.3) fig_doc=plot_vs_time(t,doc, prop_dict={'ylabel': "Degree of consolidation"}) fig_doc.gca().invert_yaxis() fig_set=plot_vs_time(t,settle, prop_dict={'ylabel': "Settlement"}) fig_set.gca().invert_yaxis() plt.show()