histo_1d_d.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """Insert a Figure into another (note that the x-axes stay aligned)"""
  2. from vedo import Marker, settings, show, np
  3. from vedo.pyplot import histogram
  4. settings.default_font = "Ubuntu"
  5. data = np.random.normal(loc=100, size=1000) + 7
  6. ################## Create the first Figure
  7. fig1 = histogram(
  8. data,
  9. bins=20,
  10. xlim=(95,111),
  11. aspect=16/9,
  12. xtitle="shifted gaussian",
  13. c='cyan3',
  14. )
  15. # let's add an asterix marker where the mean is
  16. fig1 += Marker('a', [fig1.mean,150,0.1], s=8).c('orange5')
  17. ################## Create a second Figure
  18. fig2 = histogram(
  19. data - 7,
  20. bins=60,
  21. aspect=4/3,
  22. density=True,
  23. outline=True,
  24. c='purple9',
  25. axes=dict(xygrid=True, xyplane_color='grey2', xyalpha=1, grid_linewidth=0),
  26. label='finer binning',
  27. )
  28. # let's add an asterix marker where the mean is
  29. fig2 += Marker('a', [fig2.mean,0.2,0.1], s=0.02).c('orange5')
  30. # shift fig2 in vertical by 25, and in z by 0.1 (to make it show on top)
  31. fig2.shift(0, 25, 0.1)
  32. ################## Insert fig2 into fig1
  33. fig2.add_legend()
  34. fig1.insert(fig2)
  35. show(fig1, __doc__, zoom='tight', size=(1200,900)).close()