In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to use Python to draw patterns". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Globe wiring
According to the display of the globe area, add lines to the corresponding position graph, the perfect linear globe detailed code is as follows:
`import plotly.express as pxdf = px.data.gapminder.query ("year = = 2007") fig = px.line_geo (df, locations= "iso_alpha", color= "continent", # "continent" is one of the columns of gapminderprojection= "orthographic") fig.show`
The display result is: * *
Add lines to the map
Add latitude and longitude after drawing the corresponding map, and then draw the corresponding lines according to the longitude and latitude. The detailed code is as follows:
Importplotly.graph_objectsasgofig = go.Figure (data=go.Scattergeo (lat = [3.86,53.55], lon = [73.66,135.05], mode = 'lines',line = dict (width = 2, color =' red'),) fig.update_layout (geo = dict (resolution = 50 showland = True,showlakes = True,landcolor = 'rgb (203,203,203)', countrycolor = 'rgb (204,204,204)', lakecolor = 'rgb (255,255,255)', projection_type = "equirectangular") Coastlinewidth = 3herolataxis = dict (range = [20,60], showgrid = True,dtick = 10), lonaxis = dict (range = [- 100,20], showgrid = True,dtick = 20),) `fig.show`
The display results are as follows:
The final benefit-3D picture appreciation
Finally, add a 3D image appreciation, and the detailed code for making the image is as follows:
# Import package importplotly.graph_objectsasgofromplotly.subplotsimportmake_subplotsimportnumpyasnpN = 50fig = make_subplots (rows=2, cols=2,specs= [[{'is_3d': True}, {' is_3d': True}], [{'is_3d': True}, {' is_3d': True}]], print_grid=False) for i in [1 for j in 2]: fig.append_trace (go.Mesh4d (x = (50*np.random.randn (N)), y = (20*np.random.randn (N) Z = (40*np.random.randn (N)), opacity=0.5,), row=i, col=j) `fig.update_layout (width=700, margin=dict (ritual 9, lumped 9, bimodal 9, tweak 9)) # fix the ratio in the upper left subgraph to the cube fig.update_layout (scene_aspectmode='cube') # manually force the z axis to be displayed as twice the size of the other two fig.update_layout (scene2_aspectmode='manual',scene2_aspectratio=dict (x, y) 1 Fig.update_layout (scene3_aspectmode='data') # use "data" as the default value to automatically generate well-proportioned content fig.update_layout (scene4_aspectmode='auto') # display fig.show`
The display results are as follows:
This is the end of the content of "how to draw patterns with Python". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.