basemap: How to remove actual lat/lon lines while keeping the ticks on the axis

2024/10/13 2:20:35

I plotted a map by basemap as below:

plt.figure(figsize=(7,6))
m = Basemap(projection='cyl',llcrnrlat=40.125,urcrnrlat=44.625,\llcrnrlon=-71.875,urcrnrlon=-66.375,resolution='h')
m.drawparallels(np.arange(int(40.125),int(44.625),1),labels=[1,0,0,0])
m.drawmeridians(np.arange(int(-71.875),int(-66.375),1),labels=[0,0,0,1])
m.drawcoastlines()
m.fillcontinents(color='grey')
m.drawmapboundary()

The picture as below: enter image description here

How can I remove actual lat/lon lines while keeping the ticks on the axis?

Answer

This can be easily achieved by setting the linewidth parameter to zero

m.drawparallels(np.arange(int(40.125),int(44.625),1),labels=[1,0,0,0], linewidth=0.0)
m.drawmeridians(np.arange(int(-71.875),int(-66.375),1),labels=[0,0,0,1], linewidth=0.0)

enter image description here

https://en.xdnf.cn/q/69584.html

Related Q&A

Re-initialize variables in Tensorflow

I am using a Tensorflow tf.Saver to load a pre-trained model and I want to re-train a few of its layers by erasing (re-initializing to random) their appropriate weights and biases, then training those …

Python: invert image with transparent background (PIL, Gimp,...)

I have a set of white icons on transparent background, and Id like to invert them all to be black on transparent background. Have tried with PIL (ImageChops) but it does not seem to work with transpare…

vlookup between 2 Pandas dataframes

I have 2 pandas Dataframes as follows.DF1:Security ISIN ABC I1 DEF I2 JHK I3 LMN I4 OPQ I5and DF2:ISIN ValueI2 100I3 200I5 …

replacing quotes, commas, apostrophes w/ regex - python/pandas

I have a column with addresses, and sometimes it has these characters I want to remove => - " - ,(apostrophe, double quotes, commas)I would like to replace these characters with space in one s…

Reading text from image

Any suggestions on converting these images to text? Im using pytesseract and its working wonderfully in most cases except this. Ideally Id read these numbers exactly. Worst case I can just try to u…

XGBoost and sparse matrix

I am trying to use xgboost to run -using python - on a classification problem, where I have the data in a numpy matrix X (rows = observations & columns = features) and the labels in a numpy array y…

How to preserve form fields in django after unsuccessful submit?

Code from views.py:def feedback(request):if request.method == "POST":form = CommentForm(request.POST)if form.is_valid():form.save()else:print("form.errors:", form.errors)else:form =…

Idiomatic way to parse POSIX timestamps in pandas?

I have a csv file with a time column representing POSIX timestamps in milliseconds. When I read it in pandas, it correctly reads it as Int64 but I would like to convert it to a DatetimeIndex. Right now…

Apply function on each column in a pandas dataframe

How I can write following function in more pandas way:def calculate_df_columns_mean(self, df):means = {}for column in df.columns.columns.tolist():cleaned_data = self.remove_outliers(df[column].tolist()…

Compare 2 consecutive rows and assign increasing value if different (using Pandas)

I have a dataframe df_in like so:import pandas as pd dic_in = {A:[aa,aa,bb,cc,cc,cc,cc,dd,dd,dd,ee],B:[200,200,200,400,400,500,700,700,900,900,200],C:[da,cs,fr,fs,se,at,yu,j5,31,ds,sz]} df_in = pd.Data…