How to prevent a plot from the past repainting? - plot

Is there a way to prevent a plot that has already appeared from erasing itself shortly after? I'm using pinescript on TradingView and an indicator sometimes does this. I'm aware it is due to security() and lookahead_on, and that repainting in the code should be avoided entirely, but I'd like to experiment with just making sure the plot itself is permanent when it appears, irrespective as to whether the code tells it to erase itself.
Thanks for any help

It's hard to tell without seeing your code.
For security() you can use the following function:
f_secureSecurity(_symbol, _res, _src) => security(_symbol, _res, _src[1], lookahead = barmerge.lookahead_on)
For other cases, you can use the barstate.isconfirmed built-in variable together with your other conditions that feeds the plot(). barstate.isconfirmed will be true with the last update of the bar. So, in that caase, the price action would be confirmed.

Related

How to add a progress bar to a package function in r

I am running a moving window function from the package landscapemetrics. This seems to take some time as the raster is quite big. It would be really helpful to have a progress bar or something similar. How can I code something like this without having a for loop or a self-coded function to begin with? I don't know how to provide an example raster, but here is my code:
my.raster <- raster('forest2_nonforest1_min_extent.tif')
#specify window size
moving_window <- matrix(1,nrow=5,ncol=5)
#moving window analysis
tt <- window_lsm(my.raster,
window = moving_window,
level= "landscape",
what = c("lsm_l_ed"))
I need to have a visualization of the progress for the last function (#moving window analysis)
The function window_lsm() uses raster::focal() internally, which doesn't provide a progress bar itself. So without writing your own loop/moving window function I think this won't be possible, unfortunately.
As already mentioned above, the progress argument in window_lsm() refers to layers and metrics only, but not the moving window.
Not familiar with this package, but window_lsm() has an argument progress which will "print progress report" when TRUE.
Otherwise, to the best of my knowledge it's not possible to implement a true progress bar without any kind of iteration / loop. The one other option I see would be to look at the source of window_lsm(); find the outermost loop (if there is one); define your own local version of the function; and insert a progress bar incremented inside the loop (e.g. using the progress package). (Obviously, you wouldn't want to redistribute this without looking into the licensing / discussing with package devs.)
I guess another option would be to somehow develop an estimate of how long the operation might take, e.g., based on the size of your raster, then run a countdown timer in a parallel process? My hunch is this would be hard to implement and not especially accurate.

Assigning result of chain matrix multiplication to a variable in Maxima

I'm trying to assign the result of a chain matrix multiplication in Maxima to a new variable. I'm not sure as a new user why line %o6 isn't the same as the previous and fully evaluate the chain. Also why when I enter the new variable name "B" I simply have "B" returned back to me and not ([32, 32], [32, 32]). Basic questions I know but I've searched the documentation for a number of hours, and tutorials, and the syntax that I'm supposed to use here to get what I guess I was expecting as output, is still unclear to me.
I can't tell for sure, but it appears that the problem is that B : A.A.A is entered holding the shift key for at least one of the spaces, and Shift+Space is interpreted as non-breaking space instead of ordinary space. This appears to be a known bug or at least a serious misfeature in wxMaxima; see: https://github.com/wxMaxima-developers/wxmaxima/issues/1031
(I say misfeature because Shift+Space --> non-breaking space is documented in the wxMaxima documentation, but it seems like a classic example of "bad affordance"; it is all too easy to do the wrong thing without knowing it. Anyway this is just my opinion.)
I built wxMaxima from current source code and it appears that Shift+Space is now not interpreted as non-breaking space in code, so B : A.A.A should have the expected effect even if shift key is held while typing space. The current version is 19.07.0-DevelopmentSnapshot. I poked through the commit log a bit, but I can't figure out which commit changed the behavior of Shift+Space, so it's possible that the problem is not fixed and it is just fortuitous that I am not encountering it.
There are two workarounds, if one doesn't want to hazard an upgrade. (1) Omit spaces. (2) Be careful to only type space without shift.
Hope this is helpful in some way.

bokeh update high level chart with javascript callback

I am using bokeh to plot high level chart (Line) with a dataframe .
I have also widget to filter data showed by the graph.
I know how to do it with basic glyphs but not with high level charts.
Indeed basic plots are using ColumnDataSource as input and a javascript callback can take it as argument and trigger it. But for a dataframe as input, it does not seem possible.
I have the following error if I want to pass in args the dataframe df:
ValueError: expected an element of Dict(String, Instance(Model)), got {'df': ......
Any idea?
Thanks.
David
I think the only way to do that is by re-creating the entire plot each time and replacing it. See https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/Hn14aDN_5lk for example. I would stick with using a ColumnDataSource.
I have also to precise that I don't want to use a bokeh server but a standalone solution.
As a workaround I tried to replace the dataframe by a dataframe generated by a columndatasource like this :
plot=Line(source.data,x='x',y='y')
or
plot=Line(source.to_df(),x='x',y='y')
with source=ColumnDataSource(df)
No more errors but nothing happens when triggering source in javascript callback.
Is it normal?
Thanks.
David
If you use
plot=Line(source.data,x='x',y='y') or plot=Line(source.to_df(),x='x',y='y')
then it is normal that your javascript callback doesn't trigger anything. Because you didn't pass any source to the line, you gave it the dictionary "data" from the source as defined in your python code at that time, and it will never change.
As said in the link of Okonomiyaki's answer, you should use bokeh.plotting if you want more interactions with js callbacks.

filter by variable value in report block

I could find no relevant answers in either StackOverflow or google. Perhaps one of you has the answer. This is a continuation from a previous question...
In Business Objects Webi, I have two variables. One dimension, one measure. My goal is to create a simple pie chart.
Here's the dimension variable titled "EWFMCodeSelect":
`=If([Code]InList("BRK1"; "BRK2"; "BRK3" )) Then"BREAK"
ElseIf([Code]InList("TEAM"; "MTG"; "MTNG"; "PROJ"; "TRNG";"WCGB")) Then "DISC"
ElseIf([Code]InList("LUNCH")) Then "LUNCH"
ElseIf([Code]InList("LATE";"NOSHOW";"UNPAID";"UPVAC")) Then "MISS"
ElseIf([Code]InList("COACH";"VTO")) Then "NEUTR"
ElseIf([Code]InList("VAC";"LOA";"SICKUP";"SICKPL")) Then "NODISC"
ElseIf([Code]InList("PREP")) Then "OTHER"
ElseIf([Code]InList("OVER")) Then "OVER"
Else("SHIFT")`
This is the measure variable titled EWFMPieChart(%):
=[TimeDiff (ToInt)]
/ NoFilter(( Sum([TimeDiff (ToInt)]
ForAll([EWFMCodeSelect])
Where ([EWFMCodeSelect] = "SHIFT")))ForEach())
The previous advice I received was to filter the value "SHIFT" from the report block. I thought this would be a simple affair but it's proving more difficult than anticipated. I tried creating a Report Block filter in the Analysis tab "EWFMCodeSelect Not Equal To SHIFT"
"EWFMCodeSelect Not In List > SHIFT"
but only ended up with a single row, the dimension field empty, the measure field showing #MULTIVALUE. I tried a variety of other combinations but all had the same effect.
I tried a Column filter:
=[EWFMCodeSelect] Where ([EWFMCodeSelect] <> "SHIFT")
but ended up with a single row, the dimension field showing: "BREAKDISCLUNCH..." as the value and the measure, again, showing #MULTIVALUE.
I'm missing some important clue here. Can anyone educate me either why this approach is incorrect and maybe supply me with a direction to achieve my goal?
Thanks,
mfc
I don't have the correct answer but I did solve the problem by cleaning up all of the TEST variables, deleting all unused and unnecessary errata that collected up to this point and re-running the report as a scheduled item. I also cleared the browser cache (never bad advice).
After re-opening the report, I was able to filter the report block without issue.
I guess the answer is "When in doubt and receiving undocumented results, clean up your work-space and try again".

Get Scilab to calculate without printing result

This sounds like a silly question, but I really can't find an answer around.
I'm using Scilab to evaluate two methods in terms of performace. However, every time I tell Scilab to calculate anything, it will print the results. Since I'm using large matrices, it spends much more time printing the results than doing the calculations, so I'm having a hard time telling how long is each method actually taking.
Can I get Scilab to compute something without printing the result?
That is, instead of
-->B = A'*A
A =
1. 2. 3.
2. 4. 6.
3. 6. 9.
-->
I'd like it to do
-->B = A'*A
-->
Also simply adding a semicolon works
-->B = A'*A;
-->
Well, I finally found the right query. When I searched for 'scilab silent', one of the results (not the first) was this:
http://help.scilab.org/docs/5.3.3/en_US/mode.html
Function mode(k) lets you choose how Scilab will behave in terms of variable display. The following call will temporarily hide results:
mode(-1)
Whereas this will get you back to the default option:
mode(2)
The documentation is confusing, though.
Please notices that mode does not used at prompt, only in an exec-file or a scilab function.
Aside from the awful English, this notice seems to be outdated. This function worked perfectly for me on the prompt.

Resources