I am new to Google Maps - I am trying to change the color of the second polyline on my map.
Here is what I have so far ~
var direction = new GDirections();
direction.load("from: Oregon 99, near, Halsey, Oregon to: Oregon 34, near, Tangent, Oregon to: Interstate 5, near, Tigard, Oregon to: Oregon 217, near, Cedar Hills, Oregon to: U.S. 26, near, North Plains, Oregon to: U.S. 26, near, Tigard, Oregon to: Interstate 405, near, Portland, Oregon to: Interstate 5, near, Vancouver, Wa to: Interstate 5, near, Carrolls, Wa to: Washington 432, near, Longview, Wa to: Washington 433, near, Rainier, Oregon to: U.S. 30, Wauna, Oregon", {getPolyline:true});
GEvent.addListener(direction,
"load",
function(){ map.addOverlay(direction.getPolyline()); }
);
Can someone help me change this polyline to any other color.
You can try putting direction.getPolyline() into a variable before adding it as an overlay, then after that call GPolyline.setStrokeStyle(GPolyStyleOptions) on it after adding it. Here are some references for GPolyline.setStrokeStyle() and GPolyStyleOptions
Related
I am writing code for my internship and I am adding the latitude and longitude of the area we are viewing. The section of code giving me trouble looks like this. I want to be able to have the number and then a W to show it is degrees west for my X axis and a N for my Y axis to show that it is degrees north. I have tried to use plt.ylabel("Degrees North") and that did not work as well. Any help would be greatly appreciated.
ax.set_xticks([-94, -96, -98, -100, -102, -104])
ax.set_yticks([28, 30, 32, 34, 36])
secax = ax.secondary_yaxis(1.0)
secax.set_yticks([28, 30, 32, 34, 36])
This is what the output of my code looks like
Once you plot your graph, you can get the labels using get_xticks(). Add a ' W' or ' N' and use set_yticklabels to update the labels. As your labels are int, you will need to convert them to str just before plotting. As the map is that of Texas, assuming there only North and West to be added.
Sample below has a blank matplotlib plot which gets updated.
Code
fig, ax=plt.subplots(figsize=(6,6))
plt.setp(ax, xlim = (-104, -94))
plt.setp(ax, ylim = (28, 36))
ax.set_xticks([-94, -96, -98, -100, -102, -104])
ax.set_yticks([28, 30, 32, 34, 36])
secax = ax.secondary_yaxis(1.0)
secax.set_yticks([28, 30, 32, 34, 36])
#For x-axis
labels=ax.get_xticks().tolist()
new_labels = [str(l) + " W" for l in labels]
ax.set_xticklabels(new_labels)
#For y-axis (left)
labels=ax.get_yticks().tolist()
new_labels = [str(l) + " N" for l in labels]
ax.set_yticklabels(new_labels)
#For y-axis (right)
labels=secax.get_yticks().tolist()
new_labels = [str(l) + " N" for l in labels]
secax.set_yticklabels(new_labels)
Output plot
I would like to delete the lines which are actually shown in the picture and also put the number (their values) in each graph, I mean the value which belong to each one. How can I do it?
The values are from a data set taken from Kaggle.
Here is some code to help you get the requested layout.
The states and the numbers are from Wikipedia.
import matplotlib.pyplot as plt
states = ['Acre', 'Alagoas', 'Amazonas', 'Amapá', 'Bahia', 'Ceará', 'Federal District',
'Espírito Santo', 'Goiás', 'Maranhão', 'Minas Gerais', 'Mato Grosso do Sul',
'Mato Grosso', 'Pará', 'Paraíba', 'Pernambuco', 'Piauí', 'Paraná', 'Rio de Janeiro',
'Rio Grande do Norte', 'Rondônia', 'Roraima', 'Rio Grande do Sul', 'Santa Catarina',
'Sergipe', 'São Paulo', 'Tocantins']
fires = [2918, 73, 7625, 24, 2383, 327, 68, 229, 1786, 5596, 2919, 451, 15476, 10747, 81, 132,
2818, 181, 396, 68, 6441, 4608, 2029, 1107, 62, 1616, 6436]
fires, states = zip(*sorted(zip(fires, states))) #sort both arrays on number of fires
fires = fires[-15:] # limit to the 15 highest numbers
states = states[-15:]
fig, ax = plt.subplots(figsize=(8, 6))
ax.barh(states, fires, color="#08519c")
plt.box(False) # remove the complete box around the plot
plt.xticks([]) # remove all the ticks on the x-axis
ax.yaxis.set_ticks_position('none') # removes the tick marks on the y-axis but leaves the text
for i, v in enumerate(fires):
ax.text(v + 180, i, f'{v:,}'.replace(',', '.'), color='#08519c', fontweight='normal', ha='left', va='center')
plt.subplots_adjust(left=0.22) # more space to read the names
plt.title('Wildfires Brazil 2019', fontsize=20, y=0.98) # title larger and a bit lower
plt.show()
PS: about
for i, v in enumerate(fires):
ax.text(v + 180, i, f'{v:,}'.replace(',', '.'), color='#08519c', fontweight='normal', ha='left', va='center')
This has a v going through each element of fires, one by one. i is the index for which fires[i] == b. ax.text(x, y, 'some text') puts a text on a certain position, where they are measured with the same distances as those marked on the axes (that's why default the axes are shown). When the axes are just text instead of numbers, they are numbered internally 0, 1, 2, 3, ... . So, x=v + 180 is the x-position where number-of-fires v+180 would be. And y=i means just the position of label number i.
I am using pyflux ARIMAX model and i want to extract the parameter coefficients and p-values. I have gone through the documentation, but couldn't find anything. I tried model.params but it gave me following error. I have also tried model.coeff_, but got similar error. Any help is greatly appreciated. Thank You.
AttributeError Traceback (most recent call last)
in ()
----> 1 model.params
AttributeError: 'MLEResults' object has no attribute 'params'
Using example this example you get table
>>> model = pf.ARIMAX(data=data, formula='drivers~seat_belt+oil_crisis', ar=1, ma=1, family=pf.Normal())
... x = model.fit("MLE")
... x.summary()
Normal ARIMAX(2,0,1)
======================================================= ==================================================
Dependent Variable: drivers Method: MLE
Start Date: 1969.16666666667 Log Likelihood: -1288.9807
End Date: 1984.91666666667 AIC: 2591.9615
Number of observations: 190 BIC: 2614.6907
==========================================================================================================
Latent Variable Estimate Std Error z P>|z| 95% C.I.
======================================== ========== ========== ======== ======== =========================
AR(1) 1.4031 0.0694 20.2033 0.0 (1.267 | 1.5392)
AR(2) -0.4058 0.0599 -6.7751 0.0 (-0.5231 | -0.2884)
MA(1) -0.8534 0.0429 -19.9112 0.0 (-0.9374 | -0.7694)
Beta 1 0.0099 39.506 0.0003 0.9998 (-77.4218 | 77.4417)
Beta seat_belt 0.0021 12.3407 0.0002 0.9999 (-24.1856 | 24.1897)
Beta oil_crisis 0.0027 4.3974 0.0006 0.9995 (-8.6162 | 8.6216)
Normal Scale 227.6325
==========================================================================================================
Te get Latent Variable table line names and indexes:
>>> ind = x.z.z_indices
{'AR(1)': {'start': 0, 'end': 0}, 'AR(2)': {'start': 1, 'end': 1}, 'MA(1)': {'start': 2, 'end': 2}, 'Beta 1': {'start': 3, 'end': 3}, 'Beta seat_belt': {'start': 4, 'end': 4}, 'Beta oil_crisis': {'start': 5, 'end': 5}, 'Normal Scale': {'start': 6, 'end': 6}}
Use them to get Estimate and Std Error:
>>> est = x.z.z_list[ind['AR(1)']['start']].value
... se = x.z.z_list[ind['AR(1)']['start']].std
... print(est, se)
1.4030704563076553 0.0694474441044986
You can now calculate 95% confidence intervals:
>>> est - 1.96 * se
1.266953465862838
>>> est + 1.96 * se
1.5391874467524724
Probably a bit late to help you, but putting this out there for future reference. This is quite buried in the API documentation.
model.latent_variables.get_z_values(transformed=True)
or for a fitted model object:
model.fit().z.get_z_values(transformed=True)
I have no idea how to start but I am using information in a file called ('emp_details') which I keep opening when coding can anyone help me?
def total_salary():
file=open('emp_details.txt','r')
tsalary = 0
for line in file:
line.split('\n')
item = line.split(',')
salary: List(str) = item[1:4]
tsalary = tsalary + str(salary)
print('The total salary for all employees in the system is: ',tsalary)
anykey = input("Enter any key to return main menu")
mainMenu()
I have a file called 'emp_details' this contain all the information including the salary of each employee. I am trying to calculate the total salary of all employees.
this is the file that has been read in.
#EMP_NO, EMP_NAME, AGE, POSITION, SALARY, YRS_EMP
001, Peter Smyth, 26, Developer, 29000, 4
002, Samuel Jones, 23, Developer, 24000, 1
003, Laura Stewart, 41, DevOps, 42000, 15
004, Paul Jones, 24, Analyst, 21000, 2
005, Simon Brown, 52, Developer, 53000, 18
006, George Staples, 42, Tester, 42000, 12
007, Greg Throne, 57, DevOps, 50000, 23
008, Aston Bently, 27, Tester, 33000, 5
009, Ben Evans, 32, DevOps, 38000, 2
010, Emma Samson, 23, DevOps, 22000, 1
011, Stephanie Beggs, 43, Tester, 19000, 9
012, Sarah McQuillin, 47, DevOps, 23000, 5
013, Grace Corrigan, 48, Analyst, 44000, 16
014, Simone Mills, 32, DevOps, 32000, 11
015, Martin Montgomery, 28, Analyst, 28000, 3
it seems you are trying to reinvent a wheel of sorts(even if you don't know there is a wheel). If you utilize pandas and import as a csv, which this seems to be, this can be done in 3 lines;
import pandas as pd
f = pd.read_csv('emp_details.txt', sep=',', names = ['EMP_NO', 'EMP_NAME', 'AGE', 'POSITION', 'SALARY', 'YRS_EMP'])
df = pd.DataFrame(f)
Total = df['SALARY'].sum()
edit: after some testing I realize the txt extension makes it necessary to skip the first line, so it turns into;
import pandas as pd
f = pd.read_csv('emp_details.txt', sep=',',skiprows = [0], names = ['EMP_NO', 'EMP_NAME', 'AGE', 'POSITION', 'SALARY', 'YRS_EMP'])
df = pd.DataFrame(f)
Total = df['SALARY'].sum()
/* Written by Brandon Colchin */
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class Bar extends JApplet
{
public void paint (Graphics x)
{
super.paint( x);
//declare variables
int Mon, Tues, Wed, Thurs, Fri;
//create scanner
System.out.println("Please enter the unrealistic amount of math problems you do each day");
Scanner bar = new Scanner(System.in);
Mon = bar.nextInt();
Tues = bar.nextInt();
Wed = bar.nextInt();
Thurs = bar.nextInt();
Fri = bar.nextInt();
//create edges
x.drawLine(50, 50, 50, 300);
x.drawLine(50, 300, 350, 300);
//label edges
x.drawString("100", 25, 60);
x.drawString("90", 30, 85);
x.drawString("80", 30, 110);
x.drawString("70", 30, 135);
x.drawString("60", 30, 160);
x.drawString("50", 30, 185);
x.drawString("40", 30, 210);
x.drawString("30", 30, 235);
x.drawString("20", 30, 260);
x.drawString("10", 30, 290);
x.drawString("Mon", 65, 315);
x.drawString("Tues", 130, 315);
x.drawString("Wed", 195, 315);
x.drawString("Thurs", 260, 315);
x.drawString("Fri", 325, 315);
//draw bars
x.setColor(Color.BLUE);
x.fillRect( 60, (Mon), 40, Mon );
x.setColor(Color.RED);
x.fillRect( 125, (Tues), 40, Tues );
x.setColor(Color.CYAN);
x.fillRect( 190, (Wed), 40, Wed );
x.setColor(Color.YELLOW);
x.fillRect( 255, (Thurs), 40, Thurs );
x.setColor(Color.WHITE);
x.fillRect( 320, (Fri), 40, Fri );`
The output is a graph with 100-10 on the left and Mon-Fri on the bottom and 5 rectangles.
This is for a programming class and the requirements are: Axes must be on left and bottom of graph, the 5 numbers for the 5 bars must be user inputed.
I do not know what factors to multiply the y point and the height by to make the graph start at the corresponding number on the left of the graph (ex if user inputs 60, the graph height will match up with the 60 to the left of the graph and the bottom will stop at the x-axis edge)
Also when I am prompted to enter in 5 numbers after running the program, it makes me enter 10 numbers, even though I only have nextInt 5 times. What is weird is that the first 5 numbers inputed do NOTHING and only the last 5 numbers are used for Mon - Fri.
Any help needed