Changing plot scale by a factor in matplotlib

后端 未结 3 1270
半阙折子戏
半阙折子戏 2020-11-27 15:44

I am creating a plot in python. Is there a way to re-scale the axis by a factor? The yscale and xscale commands only allow me to turn log scale off

3条回答
  •  离开以前
    2020-11-27 16:00

    To set the range of the x-axis, you can use set_xlim(left, right), here are the docs

    Update:

    It looks like you want an identical plot, but only change the 'tick values', you can do that by getting the tick values and then just changing them to whatever you want. So for your need it would be like this:

    ticks = your_plot.get_xticks()*10**9
    your_plot.set_xticklabels(ticks)
    

提交回复
热议问题