Legend options in Stata graphs - legend

http://imageshack.us/photo/my-images/339/41988730.jpg/
I'm trying to figure out how to tweak the options for the legend in this graph (see link above). Specifically I'd like the new = part of the label to disappear. Next to each line I'd like just the name of the company. I'm using the xtline command to generate the graph. Each line on the graph should represent a distinct value of the variable "company" (there should be 11 distinct values).
xtline revenue, overlay t(week_name) i(company)
Thanks!

Use the label() sub-option of the legend() option. Here's the example on p. 474 of the Stata 12 manual:
line le_m le_f year, legend(label(1 "Males") label(2 "Females"))
You can also use the order() sub-option to order the legend entries according to the order of the curves on the graph. Type "help graph legend" for more information and links to the Manual.
However I don't find legends with so many entries to be helpful. You'd have a more readable plot if you specify "legend(off)"; "yscale(log)"; and add the appropriate label next to each curve with the Graph Editor.

Related

pine script with two indicators one overlaid on the chart and another on its own?

I am trying to write a pine script with two indicators one overlaid on the chart (EMA) and another on its own?(Stoch) I cannot seem to find any info on how to separate these (Visually) but keep them within 1 pine script, ie to be able to take trading decisions based on these.
The earlier answer from Luc is right, unfortunately. Each script can either create plots that are overlaid on the default price chart, or shown in a different pane, but not both. But there is a workaround.
Suppose you've made some non-trivial calculation in your script and you'd like to put it in different pane. E.g. the next code:
//#version=4
study(title="Stochastic", shorttitle="Stoch", format=format.price, precision=2)
periodK = input(14, title="K", minval=1)
periodD = input(3, title="D", minval=1)
smoothK = input(3, title="Smooth", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)
plot(k, title="%K", color=color.blue)
plot(d, title="%D", color=color.orange)
h0 = hline(80)
h1 = hline(20)
fill(h0, h1, color=color.purple, transp=75)
// This next plot would work best in a separate pane
someNonTrivialCalculatedSeries = close
plot(ema(someNonTrivialCalculatedSeries, 25), title="Exporting Plot")
Because they have different scale, one of them most likely will break another indicator's scale.
So you'd like show Stoch in different pine, whereas ema() should be overlayed with the main chart. For that you should make the next steps:
Turn off in the study's the extra plot to return scale to normal:
Apply to the chart the next script:
//#version=4
study("NonOverlayIndicator", overlay=true)
src = input(defval=close, type=input.source)
plot(src)
Choose in the second's script inputs source required plot from the first script:
And voilĂ  - you got the plots in different pines:
But if you want split the plots because you have retrictions on amount of studies you allowed to apply (e.g. 3 for free-account) - that won't help you.
It cannot be done. A script runs either in overlay=true mode on the chart, in which case it cannot direct plots elsewhere, or in a separate pane when overlay=false (the default).
When the script is running in a pane, it can change the color of the chart bars using barcolor(), but that's the only way it can modify the chart.
It is possible to rescale signals so that multiple bounded (e.g., 0-100, -1 to +1) signals generated by one script appear one on top of the other, but this is typically impossible in overlay mode, as the vertical scale varies with the bars on the chart. The only way for an overlay script to work with its own scale is when it uses No scale, but this prevents the indicator's plots to plot relative to price, and so the chart's bars.
Nice workaround from Michael.
Unfortunately, this only seems to work to pass data for one plot.
I would like to pass data for 3 different plots to the stock price graph.
If I try this, for 'input.source' I can only select the standard sources: "open, high, low, close ...". I can not select the data from other indicators.
If I remove plots 2 and 3, it works as Michael described.
Anybody has a workaround for the workaround..? ;-)

Data in legend doesnt match the displayed data

I have code that plot tabular data I have . The code choose everytime different row (observation) to plot and display the data and the legend with the name of the observations.
My problem is that that even if I change the displayed data using the iloc (e.g changing the rows to be displayed) , I still get the same legend .
for example:
If I use this code, that suppose to display rows 0-10:
SavitzkyGolay(db_plants.iloc[:10,5:],25,2).T.plot(title='25/06/2019 17:00',figsize=(17,10))
plt.legend(db_plants['plant'])
The result I get is this :
But when I change the iloc:
SavitzkyGolay(db_plants.iloc[12:22,5:],25,2).T.plot(title='25/06/2019 17:00',figsize=(17,10))
plt.legend(db_plants['plant'])
I get the same legend:
*I can't share the original dataframe
*The observations names are different for sure
My end goal: to have the correct observations displayed in the legend
EDIT: I have used the iloc :
SavitzkyGolay(db_plants.iloc[12:22,5:],25,2).T.plot(title='25/06/201917:00',figsize=(17,10))
plt.legend(db_plants['plant'].iloc[12:22,5:])
But I still gett error:
IndexingError: Too many indexers

MPAndroidChart: Multi-line chart with filled area issue

I am now using the MPAndroidChart to draw line chartmy chart
As you can see from the above screenshot, the color specified by me(showed in legend) is not the same as the finally filled in below the chart, is there any way to make sure that the different color will not mixed together?
Below is the code I used to draw two of the lines
LineDataSet vlfDs = new LineDataSet(vlfValues, "VLF");
vlfDs.setMode(LineDataSet.Mode.CUBIC_BEZIER);
vlfDs.setCubicIntensity(0.2f);
vlfDs.setDrawFilled(true);
vlfDs.setDrawCircles(false);
vlfDs.setLineWidth(0);
vlfDs.setCircleRadius(4f);
vlfDs.setColor(Color.YELLOW);
vlfDs.setFillColor(Color.YELLOW);
vlfDs.setFillAlpha(100);
LineDataSet lfDs = new LineDataSet(lfValues, "LF");
lfDs.setCubicIntensity(0.2f);
lfDs.setDrawFilled(true);
lfDs.setDrawCircles(false);
lfDs.setLineWidth(0);
lfDs.setCircleRadius(4f);
lfDs.setCircleColor(Color.WHITE);
lfDs.setColor(Color.GREEN);
lfDs.setFillColor(Color.GREEN);
lfDs.setFillAlpha(100);
hrvLineData = new LineData(hfDs,lfDs,vlfDs, hrDs);
hrvLineData.setValueTextSize(0);
hrvLineData.setDrawValues(false);
hrvChartView.setData(hrvLineData);
hrvChartView.invalidate();
It's turned out that I need to use setFillAlpha(255) instead of setFillAlpha(100)
You can also use something similar to the following solution which overrides the default LineChartRenderer and a uses a custom implementation of IFillFormatter to fill only the areas between the datasets.
Android - Fill the color between two lines using MPAndroidChart

WSO2: Dashboard Issues and Personalization

I am using wso2cep dashboard for displaying network traffic related information by exploiting various graphs. I was wondering if there is any way I can customize legend for each type of graph or set it globally as its create confusion for the viewer, elaborated in screen shot.
In piechart others = blue
In dest port vs src ip other = orange
One thing more
Scatter plot is shifted to left side of the window cutting ips on the y-axis and there is a space left on right side which can be used.
How can I drag the chart towards right side?
And also scatter chart is not rendering multiple y-axis values against single x-axis value. Here is the screen shot for that and values against it is plotted.
source_ip, source_port, destination_ip, destination_port, protocol
192.168.227.102,123,192.168.227.101,21,ftp
192.168.227.102,101,192.168.227.101,21,ftp
192.168.227.105,445,192.168.227.101,21,ftp
192.168.227.105,123,192.168.227.101,21,ftp
192.168.227.105,65576,192.168.227.101,22,ssh
192.168.227.109,123,192.168.227.101,22,ssh
192.168.227.109,123,192.168.227.101,22,ssh
192.168.227.109,3345,192.168.227.101,22,ssh
192.168.227.233,123,192.168.227.101,445,smb
192.168.227.233,123,192.168.227.101,445,smb
192.168.227.233,111,192.168.227.101,445,smb
192.168.227.202,123,192.168.227.101,3302,smtp
192.168.227.202,233,192.168.227.101,3302,smtp
192.168.227.102,123,192.168.227.101,3302,smtp
192.168.227.102,123,192.168.227.101,25,sql
192.168.227.102,123,192.168.227.101,25,sql
This is happening because generated gadgets are deciding the the color scale and domain dynamically based on the data that has been passed to chart.
If you want to explicitly specify the color domain and color scale you can configure those in generated gadgets by modifying the VizGrammar (which is the chart library used) configuration of the charts.
This can be done by changing chart api js file, there will be a config creation like this [1] and there add colorDomain for you predefined options like below. Then the domain will be defined statically without dynamically changing the order and the colors has to be constant
conf.colorDomain = ["MySQL","SMB","OTHER"]
Even you can define your own colors to
[1] https://github.com/wso2/carbon-analytics-common/blob/master/features/analytics-gadget-templates/org.wso2.carbon.analytics.gadget.chart.template.feature/src/main/charts/line-chart/api.js#L116

Getting sub-shapes on Layer with CreateSelection

Is it possible to use the Page.CreateSelection method to return a selection of all the shapes on a page on a given layer, INCLUDING those that are within groups?
It's easy to get the shapes that are at the page level:
ActivePage.CreateSelection( visSelTypeByLayer , 0 , "GivenLayer" )
but it doesn't seem to work with groups.
CreateSelection can also be used on a group shape to get sub-shapes, but I do not think that you can create a selection of all page shapes and group sub-shapes in a single line. You would need to build up the selection from many CreateSelection calls (one at page, and one for each group shape in the page, etc )