Trouble using plots with TabPy
See original GitHub issueI would like to be able to use plots created in Python (i.e. plots generated from matplotlib or seaborn) in my Tableau workbooks. See the below code in my attempt to make a simple sine plot and show it in a Tableau workbook.
`import json import base64 import numpy as np import math import matplotlib.pyplot as plt from tabpy.tabpy_tools.client import Client connection = Client(‘http://localhost:9004/’)
def SinePlot(freq, amp):
x = np.array(np.linspace(1,100,100))
y = []
for i in range(len(x)):
y_i = math.sin(x[i])
y.append(y_i)
i += 1
fig = plt.figure()
ax = plt.subplot(111)
ax.plot(x, y)
plt.title(‘Sine Wave’)
plt.legend(‘sin’)
fig.savefig(‘plot.png’)
data = {}
with open(‘plot.png’, mode=‘rb’) as file:
img = file.read()
data[‘img’] = base64.encodebytes(img).decode(“utf-8”)
answer = json.dumps(data)
return answer
connection.deploy(‘SinePlot Func’, SinePlot, ‘Plots a sine wave’, override = True)
print(‘done’)`
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
@ethantjones97 Are you trying to deploy a function for TabPy or call it later from Tableau? What are the steps or an example you are following?
@ethantjones97 this isn’t something that’s currently on the roadmap, but it’s an interesting idea and certainly something that exists in other products. How would you use that capability if you had it?