How to Invert the X or Y Axis

How to invert the x or y axis

There is a new API that makes this even simpler.

plt.gca().invert_xaxis()

and/or

plt.gca().invert_yaxis()

Inverting the rotation along the X and the Y axis while keeping Z intact

I realized that I had this line inverted.

let multiplication = matrix * inverse

the correct is

let multiplication = inverse * matrix

Seaborn BarPlot invert y axis and keep x axis on bottom of chart area

seaborn.barplot is a wrapper for pyplot.bar and you may use pyplot.bar to create the plot with an inverted yaxis and bars that range from the bottom of the chart to a lower value up the y axis:

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

df = pd.DataFrame({"x":range(5), "y": [1,1.2,1.4,1.6,1.8]})

plt.bar(df.x, 2*np.ones(len(df))-df.y, bottom= df.y )
plt.gca().invert_yaxis()
plt.ylim(2,0)
plt.show()

Sample Image

invert x and y axis Google charts

use the following option to rotate the axis'...

orientation: 'vertical'

see following working snippet...

  google.charts.load('current', {'packages':['line']});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {

var data = new google.visualization.DataTable();
data.addColumn('number', 'Day');
data.addColumn('number', 'Guardians of the Galaxy');
data.addColumn('number', 'The Avengers');
data.addColumn('number', 'Transformers: Age of Extinction');

data.addRows([
[1, 37.8, 80.8, 41.8],
[2, 30.9, 69.5, 32.4],
[3, 25.4, 57, 25.7],
[4, 11.7, 18.8, 10.5],
[5, 11.9, 17.6, 10.4],
[6, 8.8, 13.6, 7.7],
[7, 7.6, 12.3, 9.6],
[8, 12.3, 29.2, 10.6],
[9, 16.9, 42.9, 14.8],
[10, 12.8, 30.9, 11.6],
[11, 5.3, 7.9, 4.7],
[12, 6.6, 8.4, 5.2],
[13, 4.8, 6.3, 3.6],
[14, 4.2, 6.2, 3.4]
]);

var options = {
chart: {
title: 'Box Office Earnings in First Two Weeks of Opening',
subtitle: 'in millions of dollars (USD)'
},
orientation: 'vertical',
width: 900,
height: 500
};

var chart = new google.charts.Line(document.getElementById('linechart_material'));

chart.draw(data, google.charts.Line.convertOptions(options));
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="linechart_material"></div>

How to reverse both x and y axis in Octave?

Use the following code in "figure" section:

set (gca (), "xdir", "reverse")
set (gca (), "ydir", "reverse")

Source



Related Topics



Leave a reply



Submit