Visual Basic state tax calculator - vb.net

Im working on a visual basic project creating a tax calculator. Right now, i have two arrays, one for the states and one for the tax rates. States starting with A-L have the same tax rate of 2%, M-P 3.5%, and R-W 4%. Right now this is what the two arrays look like:
Dim states() As String = {"Alabama", "Alaska", "Arizona", "Arkansas",
"California", "Colorado", "Connecticut", "Delaware", "Florida",
"Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas",
"Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts",
"Michigan", "Minnesota", "Mississippi", "Missouri", "Montana",
"Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New
York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon",
"Pennsylvania", "Rhode Island", "South Carolina", "South Dakota",
"Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington",
"West Virginia", "Wisconsin", "Wyoming"}
Dim statetax() As Double = {0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02,
0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.035,
0.035, 0.035, 0.035, 0.035, 0.035, 0.035, 0.035, 0.035, 0.035, 0.035,
0.035, 0.035, 0.035, 0.035, 0.035, 0.035, 0.035, 0.035, 0.035, 0.035,
0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04, 0.04}
Then, to calculate the state tax I have a bunch of If selectstate starts with "a" "b" "c" or "d" then totalstatetax = statetax(0) * income
I was wondering if there was a simplified version, or a way or creating an index that would allow the states and state tax to coincide. any help is appreciated. thanks!

Dictionary could be right tool for the job
var stateTaxes = new Dictionary<string, decimal>
{
{ "Alabama", 0.02m },
{ "Maine", 0.035m },
// other states
}
var alabamaTaxAmount = income * stateTaxes["Alabama"];

Related

How to plot the loss & hyperparameters in RandomizedSearchCV

This is my results from RandomizedSearchCV's cv_results_.
I had 10 Kfolds here. How would you plot each alpha amount (10 total) with the loss that each of the 10 KFold's results resulted in?
I'm thinking 10 lines with the X axis being K fold split number, Y axis being Loss Amount, and each line being color coded as Alpha = n?
data =\
{'mean_fit_time': np.array([0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0]),
'std_fit_time': np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]),
'mean_score_time': np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]),
'std_score_time': np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]),
'param_alpha': np.ma.masked_array(data=[0.03, 10.0, 0.05, 0.0005, 0.1, 0.02, 0.0001, 100.0, 0.01, 1.0],
mask=[False, False, False, False, False, False, False, False, False, False],
fill_value='?', dtype=object),
'params': [{'alpha': 0.03}, {'alpha': 10.0}, {'alpha': 0.05}, {'alpha': 0.0005}, {'alpha': 0.1}, {'alpha': 0.02}, {'alpha': 0.0001}, {'alpha': 100.0}, {'alpha': 0.01}, {'alpha': 1.0}],
'split0_test_score': np.array([-0.2, -0.4, -0.2, -0.1, -0.2, -0.2, -0.1, -0.4, -0.2, -0.4]),
'split1_test_score': np.array([-0.2, -0.4, -0.2, -0.1, -0.2, -0.2, -0.1, -0.4, -0.1, -0.4]),
'split2_test_score': np.array([-0.2, -0.4, -0.2, -0.1, -0.2, -0.2, -0.1, -0.4, -0.2, -0.4]),
'split3_test_score': np.array([-0.2, -0.4, -0.2, -0.1, -0.2, -0.2, -0.1, -0.4, -0.2, -0.4]),
'split4_test_score': np.array([-0.2, -0.5, -0.2, -0.1, -0.2, -0.2, -0.1, -0.5, -0.2, -0.5]),
'split5_test_score': np.array([-0.2, -0.4, -0.2, -0.1, -0.2, -0.2, -0.1, -0.4, -0.1, -0.4]),
'split6_test_score': np.array([-0.2, -0.4, -0.2, -0.1, -0.2, -0.2, -0.1, -0.4, -0.2, -0.4]),
'split7_test_score': np.array([-0.2, -0.4, -0.2, -0.1, -0.2, -0.2, -0.1, -0.4, -0.2, -0.4]),
'split8_test_score': np.array([-0.2, -0.4, -0.2, -0.1, -0.2, -0.2, -0.1, -0.4, -0.1, -0.4]),
'split9_test_score': np.array([-0.2, -0.4, -0.2, -0.1, -0.2, -0.2, -0.1, -0.4, -0.1, -0.4]),
'mean_test_score': np.array([-0.2, -0.4, -0.2, -0.1, -0.2, -0.2, -0.1, -0.4, -0.1, -0.4]),
'std_test_score': np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]),
'rank_test_score': np.array([5, 8, 6, 1, 7, 4, 2, 8, 3, 8], dtype=np.int32)}

In TFJS, model.predict() is undefined

I used the Keras model I made by converting it to tensorflow.js. I called the model in js. I tried to predict the new value to the model. However, model.predict() is undefined.
The value of model.predict().dataSync()[0] is also undefined.
If you look at the model.summary() in js, you can see that it is a model that I made. I've put in tensor and [[]] in predict() arg'. It was all to no avail.
Attached is my model and the corresponding partial code below. I wish you could help me. If you need more code, please leave a comment. Thank you for your help.
model.json
{"format": "layers-model", "generatedBy": "keras v2.4.0", "convertedBy": "TensorFlow.js Converter v3.8.0", "modelTopology": {"keras_version": "2.4.0", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential_2", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": [null, 34], "dtype": "float32", "sparse": false, "ragged": false, "name": "dense_5_input"}}, {"class_name": "Dense", "config": {"name": "dense_5", "trainable": true, "dtype": "float32", "units": 256, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Dense", "config": {"name": "dense_6", "trainable": true, "dtype": "float32", "units": 128, "activation": "relu", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Dense", "config": {"name": "dense_7", "trainable": true, "dtype": "float32", "units": 1000, "activation": "softmax", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}}, "training_config": {"loss": "sparse_categorical_crossentropy", "metrics": [[{"class_name": "MeanMetricWrapper", "config": {"name": "accuracy", "dtype": "float32", "fn": "sparse_categorical_accuracy"}}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Adam", "config": {"name": "Adam", "learning_rate": 0.0010000000474974513, "decay": 0.0, "beta_1": 0.8999999761581421, "beta_2": 0.9990000128746033, "epsilon": 1e-07, "amsgrad": false}}}}, "weightsManifest": [{"paths": ["group1-shard1of1.bin"], "weights": [{"name": "dense_5/kernel", "shape": [34, 256], "dtype": "float32"}, {"name": "dense_5/bias", "shape": [256], "dtype": "float32"}, {"name": "dense_6/kernel", "shape": [256, 128], "dtype": "float32"}, {"name": "dense_6/bias", "shape": [128], "dtype": "float32"}, {"name": "dense_7/kernel", "shape": [128, 1000], "dtype": "float32"}, {"name": "dense_7/bias", "shape": [1000], "dtype": "float32"}]}]}
predictPose
const predictPose = (arr) => {
// Arr is array with 34 numbers as elements.
// ex) [234,123,324,.....,222]
const prediction, model;
model = loadModel();
const p = async () => {
prediction = model().predict([arr]).dataSync()[0];
//pedicttion = model().predict(tf.tensor([arr])).dataSync()[0];
};
console.log(prediction); // The result is undefined.
};
const prediction, model; will throw an error actually, you can't assign const to nothing, you can do that for let in this case as you intend to reassign the variable name later on but its unnecessary. Another issue is that you aren't even loading in any model. Based on your model.json you would need to use tf.loadLayersModel(). The code below should work.
const predictPose = async (arr) => {
const model = await tf.loadLayersModel("path to model.json");
const prediction = model.predict([arr]).dataSync()[0];
console.log(prediction);
};

OpenLayers v6.3.1 How to instantiate several polygon sub-objects that make up a TopoJSON object inserted in my Script with the “.readFeatures” method?

My TopoJSON object contains 3 polygonal sub-objects of which the first D2P1 appears with the geometry correctly drawn on the OSM map, but the other 2 polygons D2P2 and D2P3 are drawn distorted on the map turning into projected lines instead of their! correct geometry.
Could you help me to write my code correctly so that my 3 polygons appear correctly configured?
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8" />
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io#master/en/v6.
3.1/build/ol.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io#master/en/v6
.3.1/css/ol.css" type="text/css">
<style>
/*estilo de la caja del mapa*/
#map {
width: 100%;
height: 700px;
box-shadow: 5px 5px 5px #888;
}
</style>
<style>
/*estilo de los controles del mapa*/
.ol-mouse-position {
/*estilo del control de longitud y latitud */
font-size: 12px;
font-family: Arial Black;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var osm = new ol.layer.Tile({ // capa osm (Open Street Maps)
source: new ol.source.OSM()
});
// OBJETO TopoJSON
var Y = {
"type": "Topology",
"arcs": [
[
[711, 1839],
[-37, -99],
[-3, -8],
[-2, -4],
[-3, -4],
[-2, -3],
[-1, -1],
[-2, -1],
[-3, -3],
[-2, -1],
[-4, -2],
[-1, 0],
[-3, -1],
[-24, 1],
[-12, -3],
[-10, -15],
[-1, -3],
[-5, -13],
[-2, -23],
[-1, -94],
[275, -220],
[17, -31],
[34, -52],
[117, -112],
[19, -19],
[30, -142]
],
[
[1085, 986],
[-5, -9],
[0, 0],
[-30, -40],
[-47, -48],
[-18, -16],
[-21, -16],
[-45, -61],
[-16, -16],
[-4, -4],
[-101, -125],
[-28, -6],
[-5, -7],
[-3, -2],
[-3, -1],
[-7, -16],
[-573, 431],
[-1, 1],
[-12, 5],
[-9, 3],
[-157, 6],
[16, 868],
[14, 15],
[82, 49],
[599, -158]
],
[
[711, 1839],
[315, -82],
[459, -119],
[-3, -4],
[-143, -167],
[75, -84],
[-12, -10],
[-39, -51],
[-3, -3],
[-15, -16],
[-76, -26],
[-133, -211],
[-28, -44],
[-23, -36]
],
[
[2354, 410],
[-76, -313],
[-220, 43],
[-37, -140],
[-11, 11],
[-129, 128],
[-17, 17],
[-6, 5],
[-5, 2],
[-7, 3],
[-8, 2],
[-15, 4],
[-173, 40],
[-169, 39],
[-2, 6],
[3, 33],
[-239, 651],
[-21, 32],
[-86, 93],
[133, 211],
[76, 26],
[15, 16],
[3, 3],
[39, 51],
[12, 10],
[-75, 84],
[146, 171],
[2, 1],
[16, 3],
[11, 2],
[9, 1],
[16, 2],
[20, 3],
[20, 1],
[16, 2],
[21, -2],
[14, -2],
[20, -3],
[18, -4],
[21, -8],
[24, -10],
[15, -9],
[23, -14],
[39, -28],
[32, -27],
[20, -14],
[32, -18],
[22, -10],
[23, -6],
[35, -4],
[33, -5],
[41, -1],
[74, -8],
[44, -15],
[73, -32],
[101, -41],
[169, -77],
[118, -51],
[74, -35],
[12, -5],
[-15, -66],
[-41, -179],
[-69, -252],
[-35, -26],
[-3, -9],
[-7, -15],
[-14, -48],
[-4, -57],
[-7, -16],
[-39, -41],
[-14, -22],
[-21, -44],
[-23, -3],
[-15, -1],
[-9, -2],
[-8, -6],
[-10, -16],
[-5, -11],
[0, 0]
]
],
"transform": {
"scale": [0.00001991525380089962, 0.000012987212987305721],
"translate": [-98.20093192354561, 19.06017018766488]
},
"objects": {
"D2P1": {
"type": "GeometryCollection",
"geometries": [{
"arcs": [
[0, 1]
],
"type": "Polygon",
"properties": {
"Name": "(STA. MARÍA) 1 P.MARIA AUXILIO DE LOS CRISTIANOS",
"description": null,
"timestamp": null,
"begin": null,
"end": null,
"altitudeMode": null,
"tessellate": -1,
"extrude": 0,
"visibility": -1,
"drawOrder": null,
"icon": null,
"snippet": ""
}
}]
},
"D2P2": {
"type": "GeometryCollection",
"geometries": [{
"arcs": [
[-1, 2]
],
"type": "Polygon",
"properties": {
"Name": "(STA. MARÍA) 2 P. NUESTRA SEÑORA DE LA CANDELARIA",
"description": null,
"timestamp": null,
"begin": null,
"end": null,
"altitudeMode": null,
"tessellate": -1,
"extrude": 0,
"visibility": -1,
"drawOrder": null,
"icon": null,
"snippet": ""
}
}]
},
"D2P3": {
"type": "GeometryCollection",
"geometries": [{
"arcs": [
[3]
],
"type": "Polygon",
"properties": {
"Name": "(STA. MARÍA) 3 P. SEÑOR DE LAS MARAVILLAS",
"description": null,
"timestamp": null,
"begin": null,
"end": null,
"altitudeMode": null,
"tessellate": -1,
"extrude": 0,
"visibility": -1,
"drawOrder": null,
"icon": null,
"snippet": ""
}
}]
}
}
};
/* source*/
var sourceD2P1 = new ol.source.Vector({
features: (new ol.format.TopoJSON({
layers: ['D2P1']
})).readFeatures(Y, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
}),
});
var sourceD2P2 = new ol.source.Vector({
features: (new ol.format.TopoJSON({
layers: ['D2P2']
})).readFeatures(Y, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
}),
});
var sourceD2P3 = new ol.source.Vector({
features: (new ol.format.TopoJSON({
layers: ['D2P3']
})).readFeatures(Y, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
}),
});
/*LAYER.VECTOR*/
var vectorD2P1 = new ol.layer.Vector({ // ----D2P1
source: sourceD2P1,
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'green',
}),
stroke: new ol.style.Stroke({
color: 'green',
width: 1
})
})
});
var vectorD2P2 = new ol.layer.Vector({ // ----D2P2
source: sourceD2P2,
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'red',
}),
stroke: new ol.style.Stroke({
color: 'red',
width: 1
})
})
});
var vectorD2P3 = new ol.layer.Vector({ // ----D2P3
source: sourceD2P3,
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'blue',
}),
stroke: new ol.style.Stroke({
color: 'blue',
width: 1
})
})
});
var controls = ol.control.defaults().extend([
new ol.control.ScaleLine(), /*control del mapita lateral*/
new ol.control.Attribution(), /*control del letrero de Open Street Maps*/
new ol.control.MousePosition({ /*control de LONGITUD Y LATITUD en donde se coloque el mause*/
coordinateFormat: ol.coordinate.createStringXY(4),
projection: 'EPSG:4326'
}),
new ol.control.OverviewMap({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
]
}),
/*new ol.control.ZoomSlider(),*/
new ol.control.FullScreen() /*control de expancon u cerrado del mapa*/
]);
var Mivista = new ol.View({
center: ol.proj.fromLonLat([-98.2172, 19.03464]),
zoom: 12
}) //-98.197, 19.0433 puebla
var layers = [osm,
vectorD2P1, vectorD2P2, vectorD2P3,
];
// Creacion del mapa con las 3 capas
var map = new ol.Map({
/*target------*/
target: 'map',
/*layers------*/
layers: layers,
controls: controls,
/*view--------*/
view: Mivista,
});
Mivista.setRotation(-.4999) // Rota el plano 27 grados
</script>
</body>
</html>
I LEAVE YOU THE CODE THAT ANSWERS MY QUESTION, I HOPE IT WILL BE VERY USEFUL
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8" />
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io#master/en/v6.
3.1/build/ol.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io#master/en/v6
.3.1/css/ol.css" type="text/css">
<style>
/*estilo de la caja del mapa*/
#map {
width: 100%;
height: 1000px;
box-shadow: 5px 5px 5px #888;
}
</style>
<style>
/*estilo de los controles del mapa*/
.ol-mouse-position {
/*estilo del control de longitud y latitud */
font-size: 12px;
font-family: Arial Black;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var osm = new ol.layer.Tile({ // capa osm (Open Street Maps)
source: new ol.source.OSM()
});
// OBJECTO_1 TopoJSON
var geojsonObjectochentaPARROQUIAS = {
// OBJETO TopoJSON
"type": "Topology",
"arcs": [
[
[711, 1839],
[-37, -99],
[-3, -8],
[-2, -4],
[-3, -4],
[-2, -3],
[-1, -1],
[-2, -1],
[-3, -3],
[-2, -1],
[-4, -2],
[-1, 0],
[-3, -1],
[-24, 1],
[-12, -3],
[-10, -15],
[-1, -3],
[-5, -13],
[-2, -23],
[-1, -94],
[275, -220],
[17, -31],
[34, -52],
[117, -112],
[19, -19],
[30, -142]
],
[
[1085, 986],
[-5, -9],
[0, 0],
[-30, -40],
[-47, -48],
[-18, -16],
[-21, -16],
[-45, -61],
[-16, -16],
[-4, -4],
[-101, -125],
[-28, -6],
[-5, -7],
[-3, -2],
[-3, -1],
[-7, -16],
[-573, 431],
[-1, 1],
[-12, 5],
[-9, 3],
[-157, 6],
[16, 868],
[14, 15],
[82, 49],
[599, -158]
],
[
[711, 1839],
[315, -82],
[459, -119],
[-3, -4],
[-143, -167],
[75, -84],
[-12, -10],
[-39, -51],
[-3, -3],
[-15, -16],
[-76, -26],
[-133, -211],
[-28, -44],
[-23, -36]
],
[
[2354, 410],
[-76, -313],
[-220, 43],
[-37, -140],
[-11, 11],
[-129, 128],
[-17, 17],
[-6, 5],
[-5, 2],
[-7, 3],
[-8, 2],
[-15, 4],
[-173, 40],
[-169, 39],
[-2, 6],
[3, 33],
[-239, 651],
[-21, 32],
[-86, 93],
[133, 211],
[76, 26],
[15, 16],
[3, 3],
[39, 51],
[12, 10],
[-75, 84],
[146, 171],
[2, 1],
[16, 3],
[11, 2],
[9, 1],
[16, 2],
[20, 3],
[20, 1],
[16, 2],
[21, -2],
[14, -2],
[20, -3],
[18, -4],
[21, -8],
[24, -10],
[15, -9],
[23, -14],
[39, -28],
[32, -27],
[20, -14],
[32, -18],
[22, -10],
[23, -6],
[35, -4],
[33, -5],
[41, -1],
[74, -8],
[44, -15],
[73, -32],
[101, -41],
[169, -77],
[118, -51],
[74, -35],
[12, -5],
[-15, -66],
[-41, -179],
[-69, -252],
[-35, -26],
[-3, -9],
[-7, -15],
[-14, -48],
[-4, -57],
[-7, -16],
[-39, -41],
[-14, -22],
[-21, -44],
[-23, -3],
[-15, -1],
[-9, -2],
[-8, -6],
[-10, -16],
[-5, -11],
[0, 0]
]
],
"transform": {
"scale": [0.00001991525380089962, 0.000012987212987305721],
"translate": [-98.20093192354561, 19.06017018766488]
},
"objects": {
"D2P1": {
"type": "GeometryCollection",
"geometries": [{
"arcs": [
[0, 1]
],
"type": "Polygon",
"properties": {
"Name": "(STA. MARÍA) 1 P.MARIA AUXILIO DE LOS CRISTIANOS",
"description": null,
"timestamp": null,
"begin": null,
"end": null,
"altitudeMode": null,
"tessellate": -1,
"extrude": 0,
"visibility": -1,
"drawOrder": null,
"icon": null,
"snippet": ""
}
}]
},
"D2P2": {
"type": "GeometryCollection",
"geometries": [{
"arcs": [
[-1, 2]
],
"type": "Polygon",
"properties": {
"Name": "(STA. MARÍA) 2 P. NUESTRA SEÑORA DE LA CANDELARIA",
"description": null,
"timestamp": null,
"begin": null,
"end": null,
"altitudeMode": null,
"tessellate": -1,
"extrude": 0,
"visibility": -1,
"drawOrder": null,
"icon": null,
"snippet": ""
}
}]
},
"D2P3": {
"type": "GeometryCollection",
"geometries": [{
"arcs": [
[3]
],
"type": "Polygon",
"properties": {
"Name": "(STA. MARÍA) 3 P. SEÑOR DE LAS MARAVILLAS",
"description": null,
"timestamp": null,
"begin": null,
"end": null,
"altitudeMode": null,
"tessellate": -1,
"extrude": 0,
"visibility": -1,
"drawOrder": null,
"icon": null,
"snippet": ""
}
}]
}
}
};
// OBJECTO_2 TopoJSON
var geojsonObjectXXX = { // -------------------------------------------------ObjectXXX-----Municipio_TopoJSON
"type": "Topology",
"arcs": [
[
[3698, 68],
[-126, 23],
[-54, 8],
[-370, -99],
[-112, 35],
[-249, 34],
[-133, 44],
[-62, 66],
[-35, 73],
[29, 117],
[-38, 91],
[-95, 135],
[-58, 226],
[-38, 29],
[-24, 82],
[-102, 79],
[-64, 94],
[-91, 38],
[-98, 4],
[-104, -18],
[-77, -53],
[-95, -37],
[-37, -47],
[-139, -59],
[-55, -59],
[-105, -57],
[-62, -10],
[-93, 35],
[-536, -78],
[-105, 19],
[-76, 98],
[-39, 16],
[-160, 3],
[14, 30],
[59, 50],
[63, 87],
[112, 135],
[23, 71],
[-49, 67],
[-52, 37],
[-19, 0],
[-20, -17],
[-66, 9],
[-79, -8],
[-62, -14],
[-82, 14],
[-43, 3],
[-62, 63],
[-32, 81],
[9, 39],
[41, 52],
[30, 18],
[5, 40],
[13, 25],
[25, 3],
[46, -9],
[46, -1],
[38, 9],
[33, 28],
[-10, 36],
[-23, 53],
[-8, 30],
[22, 45],
[35, 110],
[2, 15],
[25, 173],
[1, 79],
[1, 142],
[-5, 202],
[28, 10],
[58, -2],
[54, 4],
[42, 16],
[13, 41],
[-94, 114],
[-39, 34],
[-6, 11],
[-8, 15],
[9, 43],
[-35, 77],
[5, 103],
[-4, 66],
[-39, 64],
[-28, 20],
[-66, 49],
[-58, 63],
[68, 31],
[18, 35],
[0, 61],
[3, 61],
[32, 55],
[38, 29],
[-80, 137],
[87, 24],
[35, 47],
[52, 23],
[96, 28],
[39, -76],
[44, -33],
[47, 42],
[30, 22],
[111, -8],
[44, 17],
[19, 62],
[28, 17],
[90, -2],
[55, 76],
[59, 91],
[20, 68],
[20, 69],
[34, 48],
[115, 70],
[27, 46],
[46, -1],
[78, -2],
[75, 71],
[92, -18],
[41, 21],
[2, 2],
[54, 90],
[68, 18],
[3, 4],
[38, 63],
[15, 45],
[51, 28],
[35, 62],
[5, 46],
[-68, 115],
[-66, 37],
[-54, 31],
[-78, 33],
[-23, 33],
[-12, 19],
[-19, -18],
[41, -92],
[-123, 10],
[-240, 19],
[39, 16],
[-23, 7],
[-98, 33],
[-27, 12],
[-37, 17],
[-144, -129],
[-16, 101],
[-113, 53],
[-45, 71],
[-186, 20],
[48, 138],
[53, -5],
[156, 112],
[-61, 124],
[-86, 32],
[52, 150],
[47, 145],
[12, 39],
[18, 39],
[2, 4],
[22, 77],
[-53, 28],
[-39, 24],
[110, 66],
[25, 15],
[14, 35],
[18, 139],
[62, -7],
[58, 85],
[91, -52],
[78, -12],
[106, -17],
[22, 86],
[5, 22],
[10, 42],
[57, 31],
[6, 36],
[-17, 37],
[-11, 8],
[-11, -5],
[1, 9],
[-29, 54],
[-4, 62],
[-3, 4],
[-18, 24],
[86, 51],
[27, -26],
[30, 34],
[15, 38],
[93, -57],
[27, 15],
[22, 15],
[8, 14],
[-5, 32],
[-15, 36],
[6, 28],
[24, 27],
[7, 42],
[62, 57],
[1, 16],
[-79, 55],
[1, 14],
[42, 25],
[21, 1],
[24, 20],
[5, 69],
[-11, 22],
[-24, 23],
[0, 13],
[4, 38],
[11, 8],
[6, 21],
[-12, 12],
[0, 16],
[15, 19],
[6, 19],
[4, 91],
[9, 10],
[-7, 19],
[14, 10],
[17, 2],
[17, -8],
[44, -7],
[23, 9],
[15, 11],
[12, 28],
[-12, 35],
[9, 8],
[-6, 101],
[10, -12],
[25, -36],
[31, 34],
[21, -30],
[3, -16],
[60, 2],
[-5, 12],
[40, -12],
[40, -17],
[37, -19],
[48, -8],
[15, 3],
[32, -3],
[29, -9],
[27, -2],
[48, 4],
[26, 2],
[29, 7],
[25, 4],
[23, 11],
[15, 10],
[22, 3],
[-1, -8],
[16, -15],
[28, -17],
[11, -10],
[3, -7],
[-3, -8],
[-18, -21],
[-3, -14],
[1, -12],
[12, -23],
[3, -10],
[-3, -11],
[-14, -11],
[-10, -14],
[-4, -20],
[4, -13],
[7, -14],
[6, -12],
[8, -24],
[15, -68],
[-1, -106],
[-5, -23],
[-2, -64],
[-5, -17],
[-16, -36],
[17, -9],
[25, -4],
[40, 4],
[40, 9],
[28, 16],
[20, 19],
[43, -1],
[16, 10],
[16, -6],
[23, -22],
[77, -31],
[123, -53],
[83, -43],
[22, -7],
[125, -52],
[210, -80],
[174, -74],
[45, -19],
[44, -14],
[61, 12],
[14, 5],
[12, 7],
[4, 5],
[9, 4],
[2, 3],
[10, 3],
[38, 27],
[3, 3],
[3, 5],
[2, 5],
[0, 4],
[5, 8],
[27, -18],
[18, -12],
[31, 42],
[39, 35],
[58, 34],
[129, 56],
[53, 30],
[34, 21],
[29, 21],
[63, 48],
[33, 14],
[20, 6],
[19, 1],
[24, 6],
[15, 6],
[19, 13],
[213, 202],
[161, 201],
[31, 79],
[22, 52],
[93, 97],
[86, 64],
[37, 63],
[112, 50],
[-11, 11],
[46, 16],
[22, 16],
[24, 28],
[12, 4],
[70, 27],
[15, 10],
[19, 7],
[16, 9],
[7, 15],
[2, 13],
[3, 9],
[7, 8],
[20, 16],
[13, 11],
[15, 9],
[11, 19],
[24, 10],
[13, 9],
[9, 1],
[11, 5],
[11, 1],
[18, -2],
[22, -2],
[44, 0],
[38, 32],
[6, 56],
[-7, 76],
[30, 76],
[93, 127],
[209, 2],
[33, -1],
[118, -5],
[120, 116],
[203, 130],
[178, 202],
[177, 151],
[141, 43],
[124, 102],
[137, 213],
[133, 176],
[127, 158],
[12, 217],
[51, 110],
[94, -27],
[65, -115],
[6, -171],
[3, -22],
[241, -231],
[-135, -147],
[-47, 16],
[-6, -79],
[-126, -184],
[-13, -90],
[-71, 70],
[-52, -46],
[1, -114],
[35, -117],
[-16, -246],
[3, -183],
[-1, -35],
[-50, -141],
[1, -113],
[-46, -302],
[57, -66],
[136, 198],
[86, 8],
[-24, -126],
[-65, -35],
[-13, -69],
[-13, -72],
[-34, -43],
[-34, -102],
[-87, 11],
[-37, -13],
[-81, -95],
[-61, -33],
[-89, -50],
[16, -78],
[-18, -75],
[-67, -46],
[-130, -61],
[-22, -37],
[43, -182],
[-22, -105],
[-42, -20],
[-27, -5],
[-24, -8],
[-37, -65],
[-65, -47],
[-70, -17],
[-103, -52],
[-74, -89],
[-6, -101],
[-36, -43],
[-46, -146],
[-97, -161],
[-22, -93],
[-31, -21],
[-46, -165],
[-54, -190],
[-4, -40],
[77, -92],
[28, -57],
[-1, 0],
[-315, 73],
[-74, 2],
[-138, 4],
[-162, -25],
[-132, -20],
[-157, -3],
[-65, -52],
[-24, -160],
[-42, -30],
[-7, -15],
[2, -29],
[21, 6],
[23, -32],
[-104, 0],
[-12, -2],
[-254, -4],
[1, -12],
[-29, 0],
[0, -25],
[-42, 4],
[-93, 9],
[2, -7],
[-7, 0],
[-27, -1],
[-23, -13],
[0, -16],
[48, -67],
[40, -5],
[38, -6],
[44, -6],
[40, -31],
[11, -8],
[39, -30],
[32, -26],
[93, -72],
[-26, -120],
[-159, -128],
[-12, -10],
[-23, -139],
[-24, -149],
[-118, -199],
[44, -84],
[-23, -60],
[-28, 22],
[-17, -29],
[-75, -43],
[-73, -9],
[-4, -18],
[-45, -53],
[51, -150],
[70, -150],
[19, -90],
[-65, -91],
[-21, -30],
[3, -345],
[-10, -48],
[14, -49],
[-29, -32],
[13, -18],
[34, -47],
[-2, -32],
[-3, -41],
[85, -25],
[62, -46],
[70, -52],
[80, -33],
[193, -65],
[80, -66],
[55, -138],
[-38, -73],
[23, -56],
[278, -196],
[92, -53],
[117, -37],
[118, -210],
[-120, -1],
[-185, -48],
[-77, 56],
[-285, -61],
[-28, -169],
[-205, -26],
[67, 172],
[-131, 34],
[-3, 73],
[-174, 7],
[-16, -66],
[-50, -23],
[-54, 33],
[-208, -45],
[-43, -70],
[-42, -3],
[-70, -39],
[-162, -442],
[-7, -315],
[-153, -388],
[-11, -185],
[-98, -58]
]
],
"transform": {
"scale": [3.750052683335661, 4.395371608583082],
"translate": [-10941343.283091985, 2137380.706460472]
},
"objects": {
"municipioDePuebla": {
"type": "GeometryCollection",
"geometries": [{
"arcs": [
[0]
],
"type": "Polygon",
"properties": {
"Name": "MUNICIPIO DE PUEBLA",
"description": null,
"timestamp": null,
"begin": null,
"end": null,
"altitudeMode": null,
"tessellate": -1,
"extrude": 0,
"visibility": -1,
"drawOrder": null,
"icon": null,
"snippet": ""
}
}]
}
}
}; // Municipio_TopoJSON
/* ol.format.TopoJSON------------------------------------------------------------------------------------------------------------------*/
var sourceOchentaPARROQUIAS = new ol.source.Vector({
features: (new ol.format.TopoJSON({
layers: ['D2P1', 'D2P2', 'D2P3']
})).readFeatures(geojsonObjectochentaPARROQUIAS, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:3857'
})
});
var sourceMunicipio = new ol.source.Vector({
features: (new ol.format.TopoJSON()).readFeatures(geojsonObjectXXX)
});
/* ol.layer.Vector-----------------------------------------------------------------------------------------------------------------------*/
function generateRandomColor(seed) {
let r = Math.floor(Math.random() * 255)
let g = Math.floor(Math.random() * 255)
let b = Math.floor(Math.random() * 255)
return `rgba(${r}, ${g}, ${b}, 0.3)`
}
let features = sourceOchentaPARROQUIAS.getFeatures()
let colors = {}
features.forEach((feature, i) => {
let geom = feature.getGeometry()
colors[geom.ol_uid] = generateRandomColor(geom.ol_uid)
})
function vectorStyleFunction(feature) {
let geom = feature.getGeometry()
let id = geom.ol_uid
let style = new ol.style.Style({
fill: new ol.style.Fill({
color: colors[id]
}),
stroke: new ol.style.Stroke({
color: /*'rgba(9, 87, 140, 1)',*/ 'blue',
width: 1
}),
text: new ol.style.Text({
font: '12px Calibri,sans-serif',
fill: new ol.style.Fill({
color: '#000',
}),
stroke: new ol.style.Stroke({
color: '#fff',
width: 3,
}),
}),
})
// style.getText().setText(geom.ol_uid);
return style
}
var vectorLayerOchentaPARROQUIAS = new ol.layer.Vector({ // ----82 POLIGONOS
source: sourceOchentaPARROQUIAS,
style: vectorStyleFunction
});
var vectorLayerMunicipioDePuebla = new ol.layer.Vector({ // ----1 POLIGONO
source: sourceMunicipio,
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255, 255, 255, 0.00)'
}),
stroke: new ol.style.Stroke({
color: '#09a7ee',
width: 2
}),
})
});
/* CONTROLES-----------------------------------------------------------------------------------------------------------------------*/
var controls = ol.control.defaults().extend([
new ol.control.ScaleLine(), /*control del mapita lateral*/
new ol.control.Attribution(), /*control del letrero de Open Street Maps*/
new ol.control.MousePosition({ /*control de LONGITUD Y LATITUD en donde se coloque el mause*/
coordinateFormat: ol.coordinate.createStringXY(4),
projection: 'EPSG:4326'
}),
new ol.control.OverviewMap({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
]
}),
/*new ol.control.ZoomSlider(),*/
new ol.control.FullScreen() /*control de expancon u cerrado del mapa*/
]);
// Creacion del mapa con las TRES capas
var Mivista = new ol.View({
center: ol.proj.fromLonLat([-98.2172, 19.0150]),
zoom: 12
}) //-98.197, 19.0433 puebla
// pedida de capas
/*LAYERS*/
var layers = [osm, vectorLayerOchentaPARROQUIAS, vectorLayerMunicipioDePuebla];
var map = new ol.Map({
/*target------*/
target: 'map',
layers: layers,
controls: controls,
/*view--------*/
view: Mivista,
});
Mivista.setRotation(-.4999) // Rota el plano 27 grados en sentido contrario de las manecillas del reloj
</script>
</body>
</html>

How to export matplotlib plots as iframes

I want to generate some plots with Matplotlib and then generate iframes to embed in a Google Sites site.
I would like that if the image change, the change be reflected on my Google Site.
I have tried:
from matplotlib.pyplot import figure
import mpld3
fig = figure()
ax = fig.gca()
ax.plot([1,5,3,4])
hola= mpld3.save_html(fig,'myfig.html',template_type='simple')
If I open myfig.html on the browser and go to View Page Source, I can see
<script type="text/javascript" src="https://mpld3.github.io/js/d3.v3.min.js"></script>
<script type="text/javascript" src="https://mpld3.github.io/js/mpld3.v0.3.js"></script>
<style>
</style>
<div id="fig_el190911208844747686822225975"></div>
<script type="text/javascript">
!function(mpld3){
mpld3.draw_figure("fig_el190911208844747686822225975", {"width": 432.0, "height": 288.0, "axes": [{"bbox": [0.125, 0.125, 0.775, 0.755], "xlim": [-0.15000000000000002, 3.15], "ylim": [0.8, 5.2], "xdomain": [-0.15000000000000002, 3.15], "ydomain": [0.8, 5.2], "xscale": "linear", "yscale": "linear", "axes": [{"position": "bottom", "nticks": 9, "tickvalues": null, "tickformat": null, "scale": "linear", "fontsize": 10.0, "grid": {"gridOn": false}, "visible": true}, {"position": "left", "nticks": 11, "tickvalues": null, "tickformat": null, "scale": "linear", "fontsize": 10.0, "grid": {"gridOn": false}, "visible": true}], "axesbg": "#FFFFFF", "axesbgalpha": null, "zoomable": true, "id": "el19091120884476504", "lines": [{"data": "data01", "xindex": 0, "yindex": 1, "coordinates": "data", "id": "el19091120885398384", "color": "#1F77B4", "linewidth": 1.5, "dasharray": "none", "alpha": 1, "zorder": 2, "drawstyle": "default"}], "paths": [], "markers": [], "texts": [], "collections": [], "images": [], "sharex": [], "sharey": []}], "data": {"data01": [[0.0, 1.0], [1.0, 5.0], [2.0, 3.0], [3.0, 4.0]]}, "id": "el19091120884474768", "plugins": [{"type": "reset"}, {"type": "zoom", "button": true, "enabled": false}, {"type": "boxzoom", "button": true, "enabled": false}]});
}(mpld3);
So If I copy this code in my Google Sites I can see the picture.
But I need that if I save a new picture in myfig.html that I can see those changes in the site.

Google maps hide smaller cities (localites)

I am using map styler and I am trying to hide the label of all small cities. the problem is that they are all listed as localities. so if I turn off the "featureType": "locality" it turns off even big cities.
Please have a look at the location on this google maps link, you will see when you zoom out bigger cities as for example 'Brasilia' and 'Goiania' have a bigger and bolder label. While the other smaller cities around have smaller font size label.
So obviously google maps by default is styling different sizes cities differently.
https://www.google.com.au/maps/place/Faina,+State+of+Goi%C3%A1s,+Brazil/#-15.4463132,-50.4081042,8z/data=!4m2!3m1!1s0x9367dd6707a3d11d:0xd225bdabe7eabd49
how could I create my own style for those smaller cities labels?
I tried "featureType": "locality.sub_locality" but it hides all localities including the big cities.
One option would be to hid all the localities ("locality.sub_locality"), then add your own labels for the big cities that you want visible.
proof of concept fiddle using a small sample of cities from geonames.org
code snippet:
function initialize() {
var map = new google.maps.Map(document.getElementById('map-canvas'), {
styles: [{
"featureType": "administrative.locality",
"elementType": "labels",
"stylers": [{
"visibility": "off"
}]
}]
});
google.maps.event.addListener(map, 'zoom_changed', function() {
for (var i = 0; i < mapLabels.length; i++) {
if (map.getZoom() > 5) {
mapLabels[i].setVisible(true);
} else {
mapLabels[i].setVisible(false);
}
}
});
google.maps.event.addListener(map, 'bounds_changed', function() {
document.getElementById('bounds').innerHTML = map.getBounds().toUrlValue(6);
});
var bounds = new google.maps.LatLngBounds();
var mapLabels = [];
for (var i = 0; i < citiesJSON.geonames.length; i++) {
var marker = new google.maps.Marker({
position: {
lat: citiesJSON.geonames[i].lat,
lng: citiesJSON.geonames[i].lng
},
// map:map,
title: citiesJSON.geonames[i].name
});
bounds.extend(marker.getPosition());
var myOptions = {
content: citiesJSON.geonames[i].name,
boxStyle: {
border: "none",
textAlign: "center",
fontSize: "8pt",
width: "100px"
},
disableAutoPan: true,
pixelOffset: new google.maps.Size(-50, 0),
position: new google.maps.LatLng(citiesJSON.geonames[i].lat,
citiesJSON.geonames[i].lng),
closeBoxURL: "",
isHidden: false,
pane: "mapPane",
enableEventPropagation: true
};
var ibLabel = new InfoBox(myOptions);
ibLabel.open(map);
mapLabels.push(ibLabel);
}
map.fitBounds(bounds);
}
google.maps.event.addDomListener(window, "load", initialize);
var citiesJSON = {
"geonames": [{
"lng": -47.92972,
"geonameId": 3469058,
"countrycode": "BR",
"name": "Brasília",
"fclName": "city, village,...",
"toponymName": "Brasília",
"fcodeName": "capital of a political entity",
"wikipedia": "en.wikipedia.org/wiki/Bras%C3%ADlia",
"lat": -15.77972,
"fcl": "P",
"population": 2207718,
"fcode": "PPLC"
}, {
"lng": -49.25388889,
"geonameId": 3462377,
"countrycode": "BR",
"name": "Goiânia",
"fclName": "city, village,...",
"toponymName": "Goiânia",
"fcodeName": "seat of a first-order administrative division",
"wikipedia": "en.wikipedia.org/wiki/Goi%C3%A2nia",
"lat": -16.67861111,
"fcl": "P",
"population": 1171195,
"fcode": "PPLA"
}, {
"lng": -47.81027778,
"geonameId": 3451328,
"countrycode": "BR",
"name": "Ribeirão Preto",
"fclName": "city, village,...",
"toponymName": "Ribeirão Preto",
"fcodeName": "seat of a second-order administrative division",
"wikipedia": "en.wikipedia.org/wiki/Ribeir%C3%A3o_Preto",
"lat": -21.1775,
"fcl": "P",
"population": 619746,
"fcode": "PPLA2"
}, {
"lng": -48.27722222,
"geonameId": 3445831,
"countrycode": "BR",
"name": "Uberlândia",
"fclName": "city, village,...",
"toponymName": "Uberlândia",
"fcodeName": "populated place",
"wikipedia": "en.wikipedia.org/wiki/Uberl%C3%A2ndia",
"lat": -18.91861111,
"fcl": "P",
"population": 563536,
"fcode": "PPL"
}, {
"lng": -49.37944444,
"geonameId": 3448639,
"countrycode": "BR",
"name": "São José do Rio Preto",
"fclName": "city, village,...",
"toponymName": "São José do Rio Preto",
"fcodeName": "seat of a second-order administrative division",
"wikipedia": "en.wikipedia.org/wiki/S%C3%A3o_Jos%C3%A9_do_Rio_Preto",
"lat": -20.81972222,
"fcl": "P",
"population": 374699,
"fcode": "PPLA2"
}, {
"lng": -48.95277778,
"geonameId": 3472287,
"countrycode": "BR",
"name": "Anápolis",
"fclName": "city, village,...",
"toponymName": "Anápolis",
"fcodeName": "populated place",
"wikipedia": "en.wikipedia.org/wiki/An%C3%A1polis",
"lat": -16.32666667,
"fcl": "P",
"population": 319587,
"fcode": "PPL"
}, {
"lng": -47.40083333,
"geonameId": 3463011,
"countrycode": "BR",
"name": "Franca",
"fclName": "city, village,...",
"toponymName": "Franca",
"fcodeName": "seat of a second-order administrative division",
"wikipedia": "en.wikipedia.org/wiki/Franca",
"lat": -20.53861111,
"fcl": "P",
"population": 305041,
"fcode": "PPLA2"
}, {
"lng": -47.93194444,
"geonameId": 3445839,
"countrycode": "BR",
"name": "Uberaba",
"fclName": "city, village,...",
"toponymName": "Uberaba",
"fcodeName": "populated place",
"wikipedia": "en.wikipedia.org/wiki/Uberaba",
"lat": -19.74833333,
"fcl": "P",
"population": 260843,
"fcode": "PPL"
}, {
"lng": -47.95027778,
"geonameId": 3458329,
"countrycode": "BR",
"name": "Luziânia",
"fclName": "city, village,...",
"toponymName": "Luziânia",
"fcodeName": "populated place",
"wikipedia": "en.wikipedia.org/wiki/Luzi%C3%A2nia",
"lat": -16.2525,
"fcl": "P",
"population": 143601,
"fcode": "PPL"
}, {
"lng": -46.51805556,
"geonameId": 3454783,
"countrycode": "BR",
"name": "Patos de Minas",
"fclName": "city, village,...",
"toponymName": "Patos de Minas",
"fcodeName": "populated place",
"wikipedia": "en.wikipedia.org/wiki/Patos_de_Minas",
"lat": -18.57888889,
"fcl": "P",
"population": 126234,
"fcode": "PPL"
}]
};
html,
body,
#map-canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<script src="https://cdn.jsdelivr.net/npm/google-maps-utility-library-v3-infobox#1.1.14/dist/infobox.js"></script>
<div id="bounds"></div>
<div id="map-canvas" style="border: 2px solid #3872ac;"></div>