How to use the plotly.plotly function in plotly

To help you get started, we’ve selected a few plotly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github materialsproject / MPWorks / mpworks / osti_doi / __main__.py View on Github external
stream_ids=stream_ids
        )
        today = datetime.date.today()
        counts = [
            matad.matcoll.count(), matad.doicoll.count(),
            len(matad.get_all_dois())
        ]
        names = ['materials', 'requested DOIs', 'validated DOIs']
        data = Data([
            Scatter(
                x=[today], y=[counts[idx]], name=names[idx],
                stream=dict(token=stream_ids[idx], maxpoints=10000)
            ) for idx,count in enumerate(counts)
        ])
        filename = 'dois_{}'.format(today)
        print py.plot(data, filename=filename, auto_open=False)
else:
    # generate records for either n or all (n=0) not-yet-submitted materials 
    # OR generate records for specific materials (submitted or not)
    osti = OstiRecord(l=args.l, n=args.n, db_yaml=db_yaml)
    osti.submit()
github athenian-programming / object-tracking / plot_locations.py View on Github external
# Start location client
    with LocationClient(args[GRPC_HOST]) as client:

        stream_ids = tls.get_credentials_file()['stream_ids']
        stream_id = stream_ids[0]

        # Declare graph
        graph = go.Scatter(x=[], y=[], mode='lines+markers', stream=dict(token=stream_id, maxpoints=80))
        data = go.Data([graph])
        layout = go.Layout(title='Target Locations', xaxis=go.XAxis(range=[0, 800]), yaxis=go.YAxis(range=[0, 450]))
        fig = go.Figure(data=data, layout=layout)
        py.plot(fig, filename='plot-locations')

        # Write data
        stream = py.Stream(stream_id)
        stream.open()

        logger.info("Opening plot.ly tab")
        time.sleep(5)

        try:
            while True:
                x_val, y_val = client.get_xy()

                if x_val[0] == -1 or y_val[0] == -1:
                    continue

                x = x_val[1] - abs(x_val[1] - x_val[0])
                y = abs(y_val[1] - y_val[0])

                stream.write(dict(x=x, y=y))
github ismailuddin / raspberrypi / streaming-temp-neopixel / main.py View on Github external
strip.begin()

	print 'Press Ctrl-C to end this script.'

	# Plot.ly functions to stream temperature values online
	if plotting == 'plotly':

		import plotly.plotly as py
		import json
		import datetime

		with open('./config.json') as config_file:
			plotly_user_config = json.load(config_file)
			py.sign_in(plotly_user_config["plotly_username"], plotly_user_config["plotly_api_key"])

		url = py.plot([
			{
				'x' : [], 'y' : [], 'type': 'scatter',
				'stream': {
					'token': plotly_user_config['plotly_streaming_tokens'][0],
					'maxpoints': 200
				}
			
		}], filename='RPi streaming temperature')

		print("Link to Plot.ly online graph:", url)

		stream = py.Stream(plotly_user_config['plotly_streaming_tokens'][0])
		stream.open()
	else:
		pass
github basalamader / Job-Parser / Scraps.py View on Github external
were given by the first parsing process. The attributes that it will take in will be Api Username,
        ApiPassword or api_key
        :param username: this accesses is the api Username that you initially added in the first process.
        :param api_key: this is the api key that you receive after registration.
        :return: Final graph
        '''

        tls.set_credentials_file(username=username, api_key=api_key)
        data = [
            go.Scatter(
                x=self.df['jobs'], # assign x as the dataframe column 'x'
                y=self.df['number of openings']

            )
        ]
        final_graph = py.plot(data, filename='pandas/basic-bar')
        return final_graph
github cuemacro / chartpy / chartpy / engine.py View on Github external
except:
            pass

        # FRAGILE! convert matplotlib chart to Plotly format
        # recommend using AdapterCufflinks instead to directly plot to Plotly
        try:
            import plotly.plotly as py
            import plotly
            import plotly.tools as tls

            if style.convert_matplotlib_to_plotly == True:
                plotly.tools.set_credentials_file(username=style.plotly_username,
                                                  api_key=style.plotly_api_key)

                py_fig = tls.mpl_to_plotly(fig, strip_style=True)
                plot_url = py.plot_mpl(py_fig, filename=style.plotly_url)
        except:
            pass

        # display in matplotlib window (or clear from pyplot)
        try:
            if cc.chartfactory_silent_display == True:
                plt.close(fig)

                return fig
            elif style.silent_display == False:
                if not (style.block_new_plots):
                    # TODO
                    pass

                plt.show()
            else:
github TheIoTLearningInitiative / internetofthings101 / code / iotpy / projects / system.py View on Github external
def __init__(self):

        self.configuration = ConfigParser.ConfigParser()
        self.configuration.read('configuration/credentials.config')
        self.username = self.configuration.get('plotly','username')
        self.apikey = self.configuration.get('plotly','apikey')
        self.streamtokentx = self.configuration.get('plotly','streamtokentx')
        self.streamtokenrx = self.configuration.get('plotly','streamtokenrx')

        py.sign_in(self.username, self.apikey)
github r0bin-fr / ArtiGenePi / myplotly.py View on Github external
#create figure object
		fig = Figure(data=[trace1, trace2, trace3, trace4, trace5, trace6,trace7], layout=layout)

		#opening streams
		try:
			if(doinit):
				print "Init Plotly figure and layout..."
				self.weblink = py.plot(fig, filename=self.torrename)
	        		print(self.weblink)
			print "Opening Plotly streams..."
        		self.stream_tcurr = py.Stream(stream_token_tcurr)
        		self.stream_tcurr.open()
        		self.stream_tmin = py.Stream(stream_token_tmin)
        		self.stream_tmin.open()
        		self.stream_tmax = py.Stream(stream_token_tmax)
        		self.stream_tmax.open()
        		self.stream_t2 = py.Stream(stream_token_t2)
        		self.stream_t2.open()
        		self.stream_heater = py.Stream(stream_token_heater)
        		self.stream_heater.open()
        		self.stream_ror = py.Stream(stream_token_ror)
        		self.stream_ror.open()
			self.stream_zaxis = py.Stream(stream_token_zaxis)
                        self.stream_zaxis.open()

			print "Plotly streams openned with success!"
		except Exception as e:
        		print "Plotly STREAMS unexpected error:", sys.exc_info()[0], " e=",e,"\n",repr(e)

		#printer object
		self.bprint = myBTprinter.Printer()
github jackdbd / dash-fda / dash_fda / app.py View on Github external
# dash stylesheet
    "https://codepen.io/chriddyp/pen/bWLwgP.css",
    "https://fonts.googleapis.com/css?family=Lobster|Raleway",
]

if "DYNO" in os.environ:
    # the app is on Heroku
    debug = False
    # google analytics with the tracking ID for this app
    # external_js.append('https://codepen.io/jackdbd/pen/rYmdLN.js')
else:
    debug = True
    dotenv_path = os.path.join(os.path.dirname(__file__), ".env")
    load_dotenv(dotenv_path)

py.sign_in(os.environ["PLOTLY_USERNAME"], os.environ["PLOTLY_API_KEY"])
openFDA = "https://api.fda.gov/"
api_endpoint = "device/event.json?"
api_key = os.environ.get("OPEN_FDA_API_KEY")
if api_key is None:
    raise ImproperlyConfigured("openFDA API KEY not set in .env")

app_name = "Dash FDA"
server = Flask(app_name)
server.secret_key = os.environ.get("SECRET_KEY")
if server.secret_key is None:
    raise ImproperlyConfigured("Flask SECRET KEY not set in .env")
app = Dash(name=app_name, server=server, csrf_protect=False)

cache = Cache(
    app.server,
    config={
github jialinding / ChessVision / plots.py View on Github external
# 			xref='x1', yref='y1',
		# 			font=dict(color='white' if val > 0 else 'black'),
		# 			showarrow=False)
		# 		)

		layout = go.Layout(
		    title = "Board",
		    # annotations = annotations,
		    xaxis = dict(ticks=''),
		    yaxis = dict(ticks='', ticksuffix='  '),
		    width = 800,
		    height = 800
		)

		fig = go.Figure(data=data, layout=layout)
		plot_url = py.plot(fig, filename="heatmap-all-1")
	else:
		piece_class = piece_classes[piece]
		z = probabilities[piece_class,:,:]
		# data = [
		#     go.Heatmap(
		#         x=x,
		#         y=y,
		#         z=z
		#     )
		# ]

		# annotations = []
		# for n, row in enumerate(z):
		# 	for m, val in enumerate(row):
		# 		var = z[n][m]
		# 		annotations.append(
github plotly / plotly.py / plotly / io / _show.py View on Github external
def show(fig, backend=None, **kwargs):
    if backend is None:
        backend = _show_config.get('default_backend', 'ipywidgets-notebook')

    if backend == 'offline-notebook':
        plo.iplot(fig)
    elif backend == 'offline-browser':
        plo.plot(fig, auto_open=True)
    elif backend == 'online-notebook':
        display(ply.iplot(fig))
    elif backend == 'online-browser':
        ply.plot(fig, auto_open=True)
    elif backend == 'ipywidgets-notebook':
        if not isinstance(fig, go.FigureWidget):
            fig = go.FigureWidget(fig)
        display(fig)
    elif backend == 'image-ipython':
        img = to_image(fig)
        display(Image(img))
    elif backend == 'offline-qt':
        show_qt(fig, **kwargs)
    else:
        raise ValueError("Invalid backend '%s'" % backend)