我想知道是否有可能像我在下面尝试的那样将索引的名称从matplot导入到plotly中:
图表栏:
var expect = require('expect.js');
var sinon = require('sinon');
var rewire = require('rewire');
var context = require('context') // give correct path here
var app = rewire('./util.js');
var fakeContext = {
getVariable: function(s) {}
}
beforeEach(function () {
contextGetVariableMethod = sinon.stub(context, 'getVariable');
});
afterEach(function() {
contextGetVariableMethod.restore();
});
describe('feature: concat', function() {
it('should concat two strings', function() {
contextGetVariableMethod.withArgs('first_name').returns("SS");
var concat = app.__get__('concat');
expect(concat("988")).to.equal("988SS");
});
});
将Matplot栏转换为Plotly:
fig = plt.figure(figsize = (10, 5))
ax = fig.add_subplot(111)
pd.Series([10, 20, 30, 40, 50], index =['a', 'b', 'c', 'd', 'e']).plot.bar(ax = ax)
答案 0 :(得分:0)
尝试一下
import plotly.plotly as py
import plotly.graph_objs as go
data = [go.Bar(
x=['a', 'b', 'c', 'd', 'e'],
y=[10, 20, 30, 40, 50]
)]
py.plot(data, filename='basic-bar')
答案 1 :(得分:0)