xis controls the next feature from matplotlib is the ability to control the xand -axes of plot apart from basic features like setting the axis labels and colors using the methods set_xlabel(and set_ylabel()there are finer controls available as well let' first see how to add secondary -axis there are many scenarios when we plot data related to different features (having values at different scaleson the same plot to get proper understandingit usually helps to have both features on different -axis (each scaled to respective rangeto get additional -axiswe use the function twinx(exposed through the axes object the following snippet outlines the scenario #axis controls secondary -axis figax plt subplots(ax plot( , ,' 'ax set_ylabel( "primary -axis"color="green"ax ax twinx(ax plot( , ,' :',linewidth= ax set_ylabel( "secondary -axis"color="blue"plt title('secondary axis'at first it may sound odd to have function named twinx(to generate secondary -axis smartlymatplotlib has such function to point out the fact that the additional -axis would share the same -axis and hence the name twinx(on the same linesadditional -axis is obtained using the function twiny(the output plot is depicted in figure - figure - sample plot with secondary -axis