Grafana How come I dont see the Axis Tabe? - python

I looked at some screenshots in the answers as in Advanced Graphing (Part3): Right Y-axis & Log scales
Example:
But how come I dont see such Axis tab option in my Grafana (I installed it on the Raspberry Pi 4):
What is the wrong or how to enable this axis tab for my plot as well?

Related

Position of y-axis on the right side Python panel (holoviz)

how can I change the position of the y-axis labels to the right side? The standard is of course on the left side, but I want to have it on the right side.
I can’t find anything in the holoviz panel documentation to it.
I tried to derive it from the position settings of the legend. So, I thought p.y_axis_label_text_align = 'right’ could be right. However, it does not work.
Can anybody help me out or has a Python panel example where the y-axis is located on the right side of the chart tile? Thanks in advance.
The answer depends on the package you are using.
Holoviews
If your figure is created with holoviews, please cheack out the holoviews documentation for axis-positions.
In gerneal
.opts(xaxis='top', yaxis='right')
does the trick.
bokeh
If you are using the the figure of bokeh.plotting, then
p = figure(..., y_axis_location="right", ...)
moves the one y-axis to the right.
In case you want to add a new axis, the twin-axis example shows how to add a LinearAxis.

Fix x_axis and fill under curve Bokeh

I am trying to configure my Bokeh plots in Python such that they look a bit nicer. For example, is there a way to fix the maximum zoom out? Such that Bokeh cannot zoom out more than what is specified by the x-axis? E.g. look at bokeh example, and especially "Datetime axes". I would like to fix the axis size so that you cannot zoom out more than the initial x axis is wide.
Another question; is there a way to fill an area under a curve in a specified color? Like in the figure USDSEK. I can provide code, but I don't think it's necessary for the problem at hand.
UPDATED for 2019:
Bokeh now supports "directed areas" (which can also be stacked) see e.g.
https://docs.bokeh.org/en/latest/docs/gallery/stacked_area.html

How do I get interactive plots again in Spyder/IPython/matplotlib?

I upgraded from Python(x,y) 2.7.2.3 to 2.7.6.0 in Windows 7 (and was happy to see that I can finally type function_name? and see the docstring in the Object Inspector again) but now the plotting doesn't work as it used to.
Previously (Spyder 2.1.9, IPython 0.10.2, matplotlib 1.2.1), when I plotted this script, for instance, it would plot the subplots side-by-side in an interactive window:
Now (Spyder 2.2.5, IPython 1.2.0, Matplotlib 1.3.1) when I try to plot things, it does the subplots as tiny inline PNGs, which is a change in IPython:
So I went into options and found this:
which seems to say that I can get the old interactive plots back, with the 4 subplots displayed side-by-side, but when I switch to "Automatic", and try to plot something, it does nothing. No plots at all.
If I switch this drop-down to Qt, or uncheck "Activate support", it only plots the first subplot, or part of it, and then stops:
How do I get the old behavior of 4 side-by-side subplots in a single figure that I can interact with?
Change the backend to automatic:
Tools > preferences > IPython console > Graphics > Graphics backend > Backend: Automatic
Then close and open Spyder.
You can quickly control this by typing built-in magic commands in Spyder's IPython console, which I find faster than picking these from the preferences menu. Changes take immediate effect, without needing to restart Spyder or the kernel.
To switch to "automatic" (i.e. interactive) plots, type:
%matplotlib auto
then if you want to switch back to "inline", type this:
%matplotlib inline
(Note: these commands don't work in non-IPython consoles)
See more background on this topic: Purpose of "%matplotlib inline"
After applying : Tools > preferences > Graphics > Backend > Automatic Just restart the kernel
And you will get Interactive Plot.
As said in the comments, the problem lies in your script. Actually, there are 2 problems:
There is a matplotlib error, I guess that you're passing an argument as None somewhere. Maybe due to the defaultdict ?
You call show() after each subplot. show() should be called once at the end of your script. The alternative is to use interactive mode, look for ion in matplotlib's documentation.
This is actually pretty easy to fix and doesn't take any coding:
1.Click on the Plots tab above the console.
2.Then at the top right corner of the plots screen click on the options button.
3.Lastly uncheck the "Mute inline plotting" button
Now re-run your script and your graphs should show up in the console.
For most mathematical coding, I use this website and their services as they offer examples for every subject and their support is super helpful:
https://labdeck.com/application-examples-screenshots/
If your want you graph to change by a variable amount then the code you want to use is
import matplotlib.pyplot as plt
import time
vec1=[1, 2, 3, 4, 5]
vec2py=[10, 12, 9, 11, 13]
plt.show()
axes = plt.gca()
axes.set_xlim(0, 6)
axes.set_ylim(5, 50)
plt.xlabel('x - axis')
plt.ylabel('y - axis')
plt.title('Example 1')
plt.grid()
line,= axes.plot(vec1,vec2py,color='red',lw=1)
for x in range(0,10):
vec2py = [x + 2 for x in vec2py]
line.set_ydata(vec2py)
plt.draw()
plt.pause(1e-17)
time.sleep(0.5)
plt.show()
You will have to change x for how many iterations of the graph you want and how long you want it to run for and also the +2 in the vec2py line for what variable amount you want to change it by. Naturally the code is a template and you can make any aesthetical changes. This code file is found under displaying dynamic graphs which is under python programming in the link above.
If you want to display a constant rely of information from a source, I'm not to sure how to do that but the website mention before does have an example, however it isn't in python but in a simplified form of C++.If you do want to see it then the link is https://labdeck.com/examples/dsp-ecg-processing/ecg-9-leads-graphs.pdf?01a96f&01a96f and its under ECG 9 Leads graphs in ECG on the link at the start.
The graph can be shown as in a document or independently from the document.
PS this is for people who have the same question but not necessarily the same scenario as I think this will help more.

How do I control where an R plot is displayed, using python and rpy2?

I'm writing a program in Python. The first thing that happens is a window is displayed (I'm using wxPython) that has some buttons and text. When the user performs some actions, a plot is displayed in its own window. This plot is made with R, using rpy2. The problem is that the plot usually pops up on top of the main window, so the user has to move the plot to see the main window again. This is a big problem for the user, because he's lazy and good-for-nothing. He wants the plot to simply appear somewhere else, so he can see the main window and the plot at the same time, without having to lift a finger.
Two potential solutions to my problem are:
(1) display the plot within a wxPython frame (which I think I could control the location of), or
(2) be able to specify where on the screen the plot window appears.
I can't figure out how to do either.
Plot to a graphics file using jpeg(), png() or another device, then display that file on your wxWidget.
There are few lines about this in the documentation:
http://rpy.sourceforge.net/rpy2/doc-2.2/html/graphics.html
By default R plots to the "interactive" plotting device (X11). Specifying a non-interactive file-based device (jpeg, png, pdf - pdf being probably easier if rescaling or zooming is wished).
There is a very experimental feature in rpy2-2.2.0dev that would let one implement relatively easily new devices (e.g., plot into matplotlib canvases, or wxWindows panels), but unfortunately this is not complete, not documented, and probably not fully working.

Unable to specify matplotlib backend in Anaconda Spyder [duplicate]

I upgraded from Python(x,y) 2.7.2.3 to 2.7.6.0 in Windows 7 (and was happy to see that I can finally type function_name? and see the docstring in the Object Inspector again) but now the plotting doesn't work as it used to.
Previously (Spyder 2.1.9, IPython 0.10.2, matplotlib 1.2.1), when I plotted this script, for instance, it would plot the subplots side-by-side in an interactive window:
Now (Spyder 2.2.5, IPython 1.2.0, Matplotlib 1.3.1) when I try to plot things, it does the subplots as tiny inline PNGs, which is a change in IPython:
So I went into options and found this:
which seems to say that I can get the old interactive plots back, with the 4 subplots displayed side-by-side, but when I switch to "Automatic", and try to plot something, it does nothing. No plots at all.
If I switch this drop-down to Qt, or uncheck "Activate support", it only plots the first subplot, or part of it, and then stops:
How do I get the old behavior of 4 side-by-side subplots in a single figure that I can interact with?
Change the backend to automatic:
Tools > preferences > IPython console > Graphics > Graphics backend > Backend: Automatic
Then close and open Spyder.
You can quickly control this by typing built-in magic commands in Spyder's IPython console, which I find faster than picking these from the preferences menu. Changes take immediate effect, without needing to restart Spyder or the kernel.
To switch to "automatic" (i.e. interactive) plots, type:
%matplotlib auto
then if you want to switch back to "inline", type this:
%matplotlib inline
(Note: these commands don't work in non-IPython consoles)
See more background on this topic: Purpose of "%matplotlib inline"
After applying : Tools > preferences > Graphics > Backend > Automatic Just restart the kernel
And you will get Interactive Plot.
As said in the comments, the problem lies in your script. Actually, there are 2 problems:
There is a matplotlib error, I guess that you're passing an argument as None somewhere. Maybe due to the defaultdict ?
You call show() after each subplot. show() should be called once at the end of your script. The alternative is to use interactive mode, look for ion in matplotlib's documentation.
This is actually pretty easy to fix and doesn't take any coding:
1.Click on the Plots tab above the console.
2.Then at the top right corner of the plots screen click on the options button.
3.Lastly uncheck the "Mute inline plotting" button
Now re-run your script and your graphs should show up in the console.
For most mathematical coding, I use this website and their services as they offer examples for every subject and their support is super helpful:
https://labdeck.com/application-examples-screenshots/
If your want you graph to change by a variable amount then the code you want to use is
import matplotlib.pyplot as plt
import time
vec1=[1, 2, 3, 4, 5]
vec2py=[10, 12, 9, 11, 13]
plt.show()
axes = plt.gca()
axes.set_xlim(0, 6)
axes.set_ylim(5, 50)
plt.xlabel('x - axis')
plt.ylabel('y - axis')
plt.title('Example 1')
plt.grid()
line,= axes.plot(vec1,vec2py,color='red',lw=1)
for x in range(0,10):
vec2py = [x + 2 for x in vec2py]
line.set_ydata(vec2py)
plt.draw()
plt.pause(1e-17)
time.sleep(0.5)
plt.show()
You will have to change x for how many iterations of the graph you want and how long you want it to run for and also the +2 in the vec2py line for what variable amount you want to change it by. Naturally the code is a template and you can make any aesthetical changes. This code file is found under displaying dynamic graphs which is under python programming in the link above.
If you want to display a constant rely of information from a source, I'm not to sure how to do that but the website mention before does have an example, however it isn't in python but in a simplified form of C++.If you do want to see it then the link is https://labdeck.com/examples/dsp-ecg-processing/ecg-9-leads-graphs.pdf?01a96f&01a96f and its under ECG 9 Leads graphs in ECG on the link at the start.
The graph can be shown as in a document or independently from the document.
PS this is for people who have the same question but not necessarily the same scenario as I think this will help more.

Categories