Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
update plotly plot
Browse files Browse the repository at this point in the history
  • Loading branch information
whatthedev-eth committed Feb 16, 2023
1 parent 5e3dba1 commit 82760d4
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 23 deletions.
7 changes: 7 additions & 0 deletions projectile_path/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,10 @@ _not_gh_contracts
# Added by cargo

/target


# Added by cargo
#
# already existing elements were commented out

#/target
7 changes: 7 additions & 0 deletions projectile_path/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions projectile_path/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "projectile-path"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
3 changes: 3 additions & 0 deletions projectile_path/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
45 changes: 22 additions & 23 deletions projectile_path/tests/prototype_projectile_plot_rust.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 6,
"id": "e760fbb0",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -40,7 +40,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"id": "30d127c8",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -89,7 +89,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 8,
"id": "1da6fbb0",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -171,7 +171,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"id": "3c230674",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -248,7 +248,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 10,
"id": "656a02c6",
"metadata": {
"scrolled": true
Expand All @@ -260,10 +260,10 @@
"text": [
"theta_0 = 1.8325957148333336\n",
"v_0x = -25.882306286627742\n",
"v_0y = 96.59247497235584\n",
"t_max = 23.969806345067223\n",
"x_s = [0.0, -32.65230891864121, -65.30461783728242, -97.95692675592362, -130.60923567456484, -163.26154459320605, -195.91385351184724, -228.56616243048848, -261.2184713491297, -293.87078026777084, -326.5230891864121, -359.1753981050533, -391.8277070236945, -424.4800159423357, -457.13232486097695, -489.78463377961816, -522.4369426982594, -555.0892516169006, -587.7415605355417, -620.393869454183]\n",
"y_s = [0.0, 114.05942534793961, 212.52160460458768, 295.38653776994425, 362.6542248440092, 414.32466582678273, 450.39786071826467, 470.873809518455, 475.7525122273538, 465.0339688449611, 438.71817937127696, 396.8051438063011, 339.2948621500341, 266.187334402475, 177.48256056362447, 73.18054063348268, -46.718725387950826, -182.2152375006758, -333.3089957046923, -500.00000000000045]\n"
"y_s = [0.0, 114.05942534793961, 212.52160460458768, 295.38653776994425, 362.6542248440092, 414.32466582678273, 450.39786071826467, 470.873809518455, 475.7525122273538, 465.0339688449611, 438.71817937127696, 396.8051438063011, 339.2948621500341, 266.187334402475, 177.48256056362447, 73.18054063348268, -46.718725387950826, -182.2152375006758, -333.3089957046923, -500.00000000000045]\n",
"v_0y = 96.59247497235584\n"
]
}
],
Expand Down Expand Up @@ -339,7 +339,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 11,
"id": "deb3690f",
"metadata": {},
"outputs": [],
Expand All @@ -351,7 +351,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 12,
"id": "ab3f029b",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -706,7 +706,7 @@
"</div>"
]
},
"execution_count": 8,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -747,14 +747,12 @@
"metadata": {},
"source": [
"## Plot with Plotly \n",
"- but Markers error, so cannot get points w/o lines;\n",
" - see https://github.com/igiagkiozis/plotly/issues/137)\n",
"- also much slower than Plotters"
"- slower than Plotters}"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 13,
"id": "7a405bcb",
"metadata": {},
"outputs": [],
Expand All @@ -765,7 +763,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 14,
"id": "adad9ebe",
"metadata": {},
"outputs": [],
Expand All @@ -777,15 +775,15 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 15,
"id": "8f278682",
"metadata": {},
"outputs": [],
"source": [
"use ndarray::Array;\n",
"use plotly::common::{Mode, Title};\n",
"use plotly::layout::{Axis, GridXSide, Layout, LayoutGrid};\n",
"use plotly::{Plot, Scatter};\n",
"use plotly::{Plot, Scatter, Trace};\n",
"use rand_distr::{num_traits::Float, Distribution};\n",
"\n",
"// use plotly::{\n",
Expand All @@ -802,23 +800,24 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 16,
"id": "afc6e693",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
" <div id=\"rEr7Aaiep7Xcrd4fs3c3\" class=\"plotly-graph-div\" style=\"height:100%; width:100%;\"></div>\n",
" <div id=\"HKZTcIdHp6O7aP8Wwb3A\" class=\"plotly-graph-div\" style=\"height:100%; width:100%;\"></div>\n",
" <script type=\"text/javascript\">\n",
" require(['https://cdn.plot.ly/plotly-2.12.1.min.js'], function(Plotly) {\n",
" Plotly.newPlot(\n",
" \"rEr7Aaiep7Xcrd4fs3c3\",\n",
" \"HKZTcIdHp6O7aP8Wwb3A\",\n",
" {\n",
" \"data\": [\n",
" {\n",
" \"type\": \"scatter\",\n",
" \"mode\": \"markers\",\n",
" \"x\": [\n",
" 0.0,\n",
" -32.65230891864121,\n",
Expand Down Expand Up @@ -892,7 +891,7 @@
" \"config\": {}\n",
"}\n",
" ).then(function() {\n",
" var gd = document.getElementById('rEr7Aaiep7Xcrd4fs3c3');\n",
" var gd = document.getElementById('HKZTcIdHp6O7aP8Wwb3A');\n",
" var x = new MutationObserver(function (mutations, observer) { {\n",
" var display = window.getComputedStyle(gd).display;\n",
" if (!display || display === 'none') { {\n",
Expand All @@ -918,7 +917,7 @@
"</div>"
]
},
"execution_count": 12,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -928,7 +927,7 @@
"let x_s_vec: Vec<f64> = x_s.to_vec();\n",
"let y_s_vec: Vec<f64> = y_s.to_vec();\n",
"\n",
"let trace = Scatter::new(x_s_vec, y_s_vec);\n",
"let trace = Scatter::new(x_s_vec, y_s_vec).mode(Mode::Markers);\n",
"let mut plot = Plot::new();\n",
"plot.add_trace(trace);\n",
"\n",
Expand Down

0 comments on commit 82760d4

Please sign in to comment.